Implement support for reply notification formatting
This commit implements support for nicely formatting reply push notifications. Testing ------- PASS Device: iPhone 15 simulator notepush: 11568aa6285142e4c19bb0da30977957a92b7d9b Damus: This commit Settings: Local push notification setup Steps: 1. Create a post from account 1 2. On account 2, make a reply to that post 3. Ensure we get a push notification with: - A title formatted as "<ACCOUNT_2_NAME> replied to your note" - A body with the contents of that reply 4. Click on that push notification. Ensure you are taken to the reply 5. Now make a post from account 2 and mention account 1 in it 6. Ensure push notification says that account 2 mentioned account 1 (i.e. does not talk about a reply) Signed-off-by: Daniel D’Aquino <daniel@daquino.me> Closes: https://github.com/damus-io/damus/issues/2403
This commit is contained in:
@@ -70,6 +70,9 @@ struct NotificationFormatter {
|
|||||||
case .zap, .profile_zap:
|
case .zap, .profile_zap:
|
||||||
// not handled here. Try `format_message(displayName: String, notify: LocalNotification, state: HeadlessDamusState) async -> (content: UNMutableNotificationContent, identifier: String)?`
|
// not handled here. Try `format_message(displayName: String, notify: LocalNotification, state: HeadlessDamusState) async -> (content: UNMutableNotificationContent, identifier: String)?`
|
||||||
return nil
|
return nil
|
||||||
|
case .reply:
|
||||||
|
title = String(format: NSLocalizedString("%@ replied to your note", comment: "Heading for local notification indicating a new reply"), displayName)
|
||||||
|
identifier = "myReplyNotification"
|
||||||
}
|
}
|
||||||
content.title = title
|
content.title = title
|
||||||
content.body = notify.content
|
content.body = notify.content
|
||||||
|
|||||||
@@ -780,7 +780,7 @@ struct ContentView: View {
|
|||||||
selected_timeline = .dms
|
selected_timeline = .dms
|
||||||
damus_state.dms.set_active_dm(target.pubkey)
|
damus_state.dms.set_active_dm(target.pubkey)
|
||||||
navigationCoordinator.push(route: Route.DMChat(dms: damus_state.dms.active_model))
|
navigationCoordinator.push(route: Route.DMChat(dms: damus_state.dms.active_model))
|
||||||
case .like, .zap, .mention, .repost:
|
case .like, .zap, .mention, .repost, .reply:
|
||||||
open_event(ev: target)
|
open_event(ev: target)
|
||||||
case .profile_zap:
|
case .profile_zap:
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -68,6 +68,15 @@ func generate_local_notification_object(from ev: NostrEvent, state: HeadlessDamu
|
|||||||
let content_preview = render_notification_content_preview(ev: ev, profiles: state.profiles, keypair: state.keypair)
|
let content_preview = render_notification_content_preview(ev: ev, profiles: state.profiles, keypair: state.keypair)
|
||||||
return LocalNotification(type: .mention, event: ev, target: ev, content: content_preview)
|
return LocalNotification(type: .mention, event: ev, target: ev, content: content_preview)
|
||||||
}
|
}
|
||||||
|
if ev.referenced_ids.contains(where: { note_id in
|
||||||
|
guard let note_author: Pubkey = state.ndb.lookup_note(note_id)?.unsafeUnownedValue?.pubkey else { return false }
|
||||||
|
guard note_author == state.keypair.pubkey else { return false }
|
||||||
|
return true
|
||||||
|
}) {
|
||||||
|
// This is a reply to one of our posts
|
||||||
|
let content_preview = render_notification_content_preview(ev: ev, profiles: state.profiles, keypair: state.keypair)
|
||||||
|
return LocalNotification(type: .reply, event: ev, target: ev, content: content_preview)
|
||||||
|
}
|
||||||
} else if type == .boost,
|
} else if type == .boost,
|
||||||
state.settings.repost_notification,
|
state.settings.repost_notification,
|
||||||
let inner_ev = ev.get_inner_event()
|
let inner_ev = ev.get_inner_event()
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ enum LocalNotificationType: String {
|
|||||||
case dm
|
case dm
|
||||||
case like
|
case like
|
||||||
case mention
|
case mention
|
||||||
|
case reply
|
||||||
case repost
|
case repost
|
||||||
case zap
|
case zap
|
||||||
case profile_zap
|
case profile_zap
|
||||||
|
|||||||
Reference in New Issue
Block a user