diff --git a/mobile/ios/Runner/QuickSend.swift b/mobile/ios/Runner/QuickSend.swift index fd186e0b4b..c5cb88510d 100644 --- a/mobile/ios/Runner/QuickSend.swift +++ b/mobile/ios/Runner/QuickSend.swift @@ -54,15 +54,10 @@ final class QuickSendBridge { } } - /// Sends [text] to the Bestie once [confirm] accepts its name, or throws a - /// message Siri can read. + /// Sends [text] to the Bestie, or throws a message Siri can read. @MainActor - func send( - _ text: String, - deadline: Duration = .seconds(20), - confirm: (_ bestieName: String?) async throws -> Void - ) async throws { - // One at a time, so two quick sends post in the order they were confirmed. + func send(_ text: String, deadline: Duration = .seconds(20)) async throws { + // One at a time, so two quick sends post in the order they were spoken. guard !sending else { throw QuickSendError("Another message is still sending.") } sending = true defer { sending = false } @@ -73,7 +68,6 @@ final class QuickSendBridge { guard let pubkey = bestie?["pubkey"] as? String, let scope = bestie?["scope"] as? String else { throw QuickSendError("Buzz couldn't find your Bestie.") } - try await confirm(bestie?["name"] as? String) let start = ContinuousClock.now do { _ = try await call("send", arguments: ["text": text, "bestie": pubkey, "scope": scope]) @@ -116,16 +110,11 @@ struct MessageBestieIntent: AppIntent { var message: String @MainActor - func perform() async throws -> some IntentResult & ProvidesDialog { + func perform() async throws -> some IntentResult { let text = message.trimmingCharacters(in: .whitespacesAndNewlines) guard !text.isEmpty else { throw QuickSendError("Say a message to send.") } - try await QuickSendBridge.shared.send(text) { name in - try await requestConfirmation( - result: .result(dialog: "Send “\(text)” to \(name ?? "your Bestie")?"), - confirmationActionName: .send - ) - } - return .result(dialog: "Sent.") + try await QuickSendBridge.shared.send(text) + return .result() } } diff --git a/mobile/lib/features/channels/quick_send_host.dart b/mobile/lib/features/channels/quick_send_host.dart index 0b81b8888b..04857249b2 100644 --- a/mobile/lib/features/channels/quick_send_host.dart +++ b/mobile/lib/features/channels/quick_send_host.dart @@ -7,7 +7,6 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import '../../shared/me/default_agent.dart'; -import '../../shared/profile/user_cache_provider.dart'; import '../../shared/relay/relay.dart'; import '../../shared/drafts/compose_drafts_provider.dart'; import 'bestie_conversation.dart'; @@ -73,10 +72,7 @@ class QuickSendHost extends HookConsumerWidget { } } -/// The Bestie a quick send will go to, named so the person can confirm it. -/// -/// This is the saved choice, which may predate a change made on another -/// device that this one hasn't synced; naming it lets the person catch that. +/// The Bestie a quick send will go to. Future> _bestie(WidgetRef ref) async { // Captured first: a switch during the awaits must not pair this // community's scope with another's Bestie. @@ -87,31 +83,18 @@ Future> _bestie(WidgetRef ref) async { if (bestie == null) { throw const _QuickSendRefused('Choose a Bestie in Buzz first.'); } - if (ref.read(userCacheProvider)[bestie] == null) { - // Briefly: Siri can say "your Bestie" rather than keep the person waiting. - await ref - .read(userCacheProvider.notifier) - .preload([bestie]) - .timeout(const Duration(seconds: 2), onTimeout: () => false); - } _ensureScope(ref, scope); - return { - 'pubkey': bestie, - 'name': ref.read(userCacheProvider)[bestie]?.label, - 'scope': scope, - }; + return {'pubkey': bestie, 'scope': scope}; } -/// The account and community a confirmed Bestie belongs to. +/// The account and community a looked-up Bestie belongs to. String _scope(WidgetRef ref) => '${ref.read(relayConfigProvider).baseUrl} ${ref.read(myPubkeyProvider)}'; -/// Refuses a send whose confirmation was for another account or community. +/// Refuses a send whose Bestie was looked up in another account or community. void _ensureScope(WidgetRef ref, String scope) { if (_scope(ref) != scope) { - throw const _QuickSendRefused( - 'Buzz switched communities. Try again to confirm the new Bestie.', - ); + throw const _QuickSendRefused('Buzz switched communities. Try again.'); } } diff --git a/mobile/test/features/channels/quick_send_test.dart b/mobile/test/features/channels/quick_send_test.dart index ca31988a4a..0a52f7bb7d 100644 --- a/mobile/test/features/channels/quick_send_test.dart +++ b/mobile/test/features/channels/quick_send_test.dart @@ -13,7 +13,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:nostr/nostr.dart' as nostr; -import 'package:pointycastle/digests/sha256.dart'; import 'package:shared_preferences/shared_preferences.dart'; class _EmptyChannels extends ChannelsNotifier { @@ -38,9 +37,8 @@ class _Config extends RelayConfigNotifier { /// A relay that is not connected until the test says so, accepts every /// publish and serves back the DM its open command finds or creates. class _Relay extends RelaySessionNotifier { - _Relay(this.owner, this.profile); + _Relay(this.owner); final nostr.Keys owner; - final NostrEvent profile; final published = []; /// Rejects the next message the way an over-quota relay does. @@ -82,14 +80,13 @@ class _Relay extends RelaySessionNotifier { Future> queryRelay( List filters, { Duration timeout = const Duration(seconds: 8), - }) async => [profile]; + }) async => const []; @override Future> fetchHistory( NostrFilter filter, { Duration timeout = const Duration(seconds: 8), }) async { - if (filter.kinds.contains(0)) return [profile]; final ds = filter.tags['#d']; return _stored.reversed .where( @@ -183,28 +180,7 @@ void main() { SharedPreferences.setMockInitialValues({}); final prefs = await SharedPreferences.getInstance(); final owner = nostr.Keys.generate(), bestie = nostr.Keys.generate(); - final digest = SHA256Digest() - .process( - Uint8List.fromList(utf8.encode('nostr:agent-auth:${bestie.public}:')), - ) - .map((v) => v.toRadixString(16).padLeft(2, '0')) - .join(); - final profile = NostrEvent.fromJson( - nostr.Event.from( - kind: 0, - content: jsonEncode({'display_name': 'Bestie'}), - secretKey: bestie.secret, - tags: [ - [ - 'auth', - owner.public, - '', - nostr.Schnorr.sign(secretKey: owner.secret, message: digest), - ], - ], - ).toMap(), - ); - final relay = _Relay(owner, profile); + final relay = _Relay(owner); String? chosenBestie; await tester.pumpWidget( ProviderScope( @@ -251,12 +227,8 @@ void main() { replied = true; }, ); - // Ownership verification runs in a real isolate. for (var i = 0; i < 100 && !replied; i++) { await tester.pump(const Duration(milliseconds: 50)); - await tester.runAsync( - () => Future.delayed(const Duration(milliseconds: 50)), - ); } expect(replied, isTrue, reason: '$method never answered'); return (result, failure); @@ -278,9 +250,9 @@ void main() { await tester.pump(); final (named, _) = await siri('bestie'); final scope = (named! as Map)['scope']; - expect(named, {'pubkey': bestie.public, 'name': 'Bestie', 'scope': scope}); + expect(named, {'pubkey': bestie.public, 'scope': scope}); - // A confirmation from before a community switch can't send here. + // A Bestie looked up before a community switch can't send here. final (_, switched) = await siri('send', { 'text': 'Remind me to call Sam', 'bestie': bestie.public,