mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
fix(mobile): bind notification replies to the account they were typed for (#9845)
A notification reply goes out as whatever account its community signs with when the reply is sent. No sign-in path replaces a community's account in place today: signing in again as another account adds a new community, and hosted re-entry refuses a different key. But nothing tied a reply to the account its notification was for, so a future in-place credential replacement would let a reply typed for the earlier account go out as the new one, or land in its drafts. Each reply is now tied to the account its notification was for: - The notification service extension records that account in the reply context, and iOS carries it through the reply journal, so a reply recovered on a later launch keeps it too. - The app sends a reply, or keeps it as a draft, only while the community still signs as that account (the key it signs with). It checks again after connecting. - Otherwise the reply ends as lost: iOS shows "Reply not sent" with the text, and no draft is kept. This is the same path a reply takes when its community has been removed ([ADR 0004](docs/adr/0004-notification-reply.md), updated here). - A reply to a notification posted by an earlier build has no recorded account, so it is checked only by its community, as before. ### Regressions - A community whose notification snapshot has no account key offers no reply action. Every signed-in community has one, since the snapshot falls back to the key derived from its secret. - No extra work on the send path beyond a key comparison. ### Validation - [notification_reply_test.dart](https://github.com/block/buzz/blob/notification-reply-account/mobile/test/features/channels/notification_reply_test.dart): a live reply for another account and a recovered one for another community end as lost with their text kept nowhere; a reply whose community's signing key is replaced while the relay connects (same community and stored key) is neither sent nor drafted; a reply from an earlier build without an account is sent. - [BuzzNotificationReplyTests.swift](https://github.com/block/buzz/blob/notification-reply-account/mobile/ios/BuzzPushKit/Tests/BuzzPushKitTests/BuzzNotificationReplyTests.swift): the resolver records the notification's account, lowercased. An empty account is rejected, and the account survives the journal round trip. - No simulator run: the reply action needs a real push resolved by the notification service extension, which the simulator can't receive. The change is covered at both layers by the tests above, and the iOS app builds. --------- Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
@@ -6,7 +6,7 @@ The reply goes in a new subthread rooted at the notified message: its parent is
|
||||
|
||||
The reply mentions the notified message's sender, in every kind of conversation including DMs and Solo chats, so the person or agent being answered is notified. A sender who has since left the conversation can't be mentioned, so the reply goes without the mention rather than failing. A notification has no mention autocomplete, so it adds no other mentions; text typed as `@name` stays plain text.
|
||||
|
||||
After the reply is accepted, the app marks the conversation read up to the notified message and removes the delivered notifications that read marker covers (for a message in a thread, that thread's earlier ones; for a top-level message, the whole conversation's, threads included), because replying means the user has seen that message. Newer messages stay unread: the user may not have seen them. When the reply can't be sent (offline, a channel the user isn't in, no time left), the app shows a "Reply not sent" notification instead; tapping it opens the subthread the reply would have gone in, with the typed text in its composer after any draft already there, so nothing typed is lost, unless the reply's community is gone (see below). A recovered draft doesn't carry the automatic mention. iOS keeps each reply on disk from the moment it's typed until the app reports what happened to it, or until the app has saved its draft, so the text survives even when the app never got to the reply, or was stopped partway. A later launch never sends a reply an earlier one was given: it makes it a draft, unless the earlier launch had reached the point where the reply could go out, which iOS records before the app publishes; then it only says the reply may not have sent, so it can't be posted twice. A reply whose community has since been removed, including by signing out, keeps no draft: its text survives only in its "Reply not sent" notification, which a later launch posts too for a reply an earlier one was given. iOS forgets the reply only once that notification is posted; if iOS refuses it, the next launch tries again. Signing back in to the same community doesn't bring it back, because the community is added again under a new identity. A community this build hides but still stores ([ADR 0001](0001-internal-and-public-mobile-builds.md)) is not gone: its reply stays with iOS for a build that shows it.
|
||||
After the reply is accepted, the app marks the conversation read up to the notified message and removes the delivered notifications that read marker covers (for a message in a thread, that thread's earlier ones; for a top-level message, the whole conversation's, threads included), because replying means the user has seen that message. Newer messages stay unread: the user may not have seen them. When the reply can't be sent (offline, a channel the user isn't in, no time left), the app shows a "Reply not sent" notification instead; tapping it opens the subthread the reply would have gone in, with the typed text in its composer after any draft already there, so nothing typed is lost, unless the reply's community is gone (see below). A recovered draft doesn't carry the automatic mention. iOS keeps each reply on disk from the moment it's typed until the app reports what happened to it, or until the app has saved its draft, so the text survives even when the app never got to the reply, or was stopped partway. A later launch never sends a reply an earlier one was given: it makes it a draft, unless the earlier launch had reached the point where the reply could go out, which iOS records before the app publishes; then it only says the reply may not have sent, so it can't be posted twice. A reply whose community has since been removed, including by signing out, keeps no draft: its text survives only in its "Reply not sent" notification, which a later launch posts too for a reply an earlier one was given. iOS forgets the reply only once that notification is posted; if iOS refuses it, the next launch tries again. Signing back in to the same community doesn't bring it back, because the community is added again under a new identity. Each reply also remembers the account its notification was for, and is sent or kept as a draft only while its community still signs as that account. No sign-in path today replaces a community's account in place (signing in again as another account adds a new community), so this guards that invariant against a future one: a reply typed for the earlier account would survive only in its "Reply not sent" notification, never sent or kept as the new account's draft. A reply to a notification from a build that didn't record its account is checked only by its community. A community this build hides but still stores ([ADR 0001](0001-internal-and-public-mobile-builds.md)) is not gone: its reply stays with iOS for a build that shows it.
|
||||
|
||||
A reply has one deadline, set when iOS hands it to the app, about 25 seconds later. The app checks the deadline at the moment the message goes out, after any wait including a rate limit's, and publishes only while there's still time to hear the relay's answer before it. iOS also refuses to let a reply go out once it has ended it as not sent. So a reply reported as not sent was never published, or the relay refused it, and retrying its draft can't post it twice. A reply that was published but got no answer may have gone out: the app says so ("Reply may not have sent") and keeps no draft, so iOS forgets it only once that notification is posted. iOS says the same when the deadline passes after the app recorded that the reply could go out.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user