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 <jb55@jb55.com>
This commit is contained in:
alltheseas
2025-12-17 22:06:42 -06:00
committed by William Casarin
parent 71c36052e2
commit d27d4e65cb

View File

@@ -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
}