diff --git a/DamusNotificationService/NotificationFormatter.swift b/DamusNotificationService/NotificationFormatter.swift index 615eaacc..ec7a40fd 100644 --- a/DamusNotificationService/NotificationFormatter.swift +++ b/DamusNotificationService/NotificationFormatter.swift @@ -70,6 +70,9 @@ struct NotificationFormatter { case .zap, .profile_zap: // not handled here. Try `format_message(displayName: String, notify: LocalNotification, state: HeadlessDamusState) async -> (content: UNMutableNotificationContent, identifier: String)?` 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.body = notify.content diff --git a/damus/ContentView.swift b/damus/ContentView.swift index d6605b6a..5907419a 100644 --- a/damus/ContentView.swift +++ b/damus/ContentView.swift @@ -780,7 +780,7 @@ struct ContentView: View { selected_timeline = .dms damus_state.dms.set_active_dm(target.pubkey) 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) case .profile_zap: break diff --git a/damus/Models/NotificationsManager.swift b/damus/Models/NotificationsManager.swift index c32ae753..69014085 100644 --- a/damus/Models/NotificationsManager.swift +++ b/damus/Models/NotificationsManager.swift @@ -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) 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, state.settings.repost_notification, let inner_ev = ev.get_inner_event() diff --git a/damus/Util/LocalNotification.swift b/damus/Util/LocalNotification.swift index 19da4490..ad0aca98 100644 --- a/damus/Util/LocalNotification.swift +++ b/damus/Util/LocalNotification.swift @@ -63,6 +63,7 @@ enum LocalNotificationType: String { case dm case like case mention + case reply case repost case zap case profile_zap