From d27d4e65cb861f0409913c55a88f2de65fe1fb41 Mon Sep 17 00:00:00 2001 From: alltheseas <64376233+alltheseas@users.noreply.github.com> Date: Wed, 17 Dec 2025 22:06:42 -0600 Subject: [PATCH] fix: move repost dedup inside home context to fix notifications The repost deduplication logic was incorrectly placed before the context switch in handle_text_event(), causing notification events to be filtered out when the same note had already been reposted in the home feed. This fix moves the dedup logic inside the .home case where it belongs. Notifications should always show reposts of YOUR posts, even if the same note was already reposted by someone else in your home feed. Root cause: commit bed4e00 added home feed dedup but placed the logic before the context switch, affecting all contexts instead of just home. Note on nostrdb: This bug is purely in application routing logic and does not require database-level changes. The existing nostrdb TODO (about inner event validation) is unrelated to this notification issue. Changelog-Fixed: Fixed repost notifications not appearing in notifications tab Closes: #3165 Closes: https://github.com/damus-io/damus/pull/3448 Signed-off-by: alltheseas Signed-off-by: William Casarin --- .../Features/Timeline/Models/HomeModel.swift | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/damus/Features/Timeline/Models/HomeModel.swift b/damus/Features/Timeline/Models/HomeModel.swift index b61595e2..9928b262 100644 --- a/damus/Features/Timeline/Models/HomeModel.swift +++ b/damus/Features/Timeline/Models/HomeModel.swift @@ -850,21 +850,27 @@ class HomeModel: ContactsDelegate, ObservableObject { handle_quote_repost_event(ev, target: quoted_event.note_id) } - // don't add duplicate reposts to home - if ev.known_kind == .boost, let target = ev.get_inner_event()?.id { - if already_reposted.contains(target) { - Log.info("Skipping duplicate repost for event %s", for: .timeline, target.hex()) - return - } else { - already_reposted.insert(target) - } - } - switch context { case .home: + // Deduplicate reposts in home feed only (issue #859). + // + // IMPORTANT: This dedup logic must remain inside the .home case. + // Moving it outside the switch would break notification delivery + // for reposts (issue #3165). Notifications should always show + // reposts of YOUR posts, even if the same note was already + // reposted by someone else in your home feed. + if ev.known_kind == .boost, let target = ev.get_inner_event()?.id { + guard !already_reposted.contains(target) else { + Log.info("Skipping duplicate repost for event %s", for: .timeline, target.hex()) + return + } + already_reposted.insert(target) + } Task { await insert_home_event(ev) } + case .notifications: handle_notification(ev: ev) + case .other: break }