commit 7437199ef6b80a8b8d2fa0f12c70e198b42d4f6d
parent 4ee0bd4efb83841f8d1c1bab4479958ce8ef26e8
Author: William Casarin <jb55@jb55.com>
Date: Wed, 15 Jun 2022 14:43:59 -0700
don't show replies to non-friends in timeline
Changelog-Fixed: Don't show replies to non-friends in timeline
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/damus/Models/Contacts.swift b/damus/Models/Contacts.swift
@@ -214,9 +214,17 @@ func is_friend_event(_ ev: NostrEvent, our_pubkey: String, contacts: Contacts) -
return true
}
+ let pks = ev.referenced_pubkeys
+
+ // allow reply-to-self-or-friend case
+ if pks.count == 1 && contacts.is_friend(pks[0].ref_id) {
+ return true
+ }
+
// show our replies?
- for pk in ev.referenced_pubkeys {
- if contacts.is_friend(pk.ref_id) {
+ for pk in pks {
+ // don't count self mentions here
+ if pk.ref_id != ev.pubkey && contacts.is_friend(pk.ref_id) {
return true
}
}
diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift
@@ -289,7 +289,9 @@ class HomeModel: ObservableObject {
}
if sub_id == home_subid {
- let _ = insert_home_event(ev)
+ if is_friend_event(ev, our_pubkey: damus_state.pubkey, contacts: damus_state.contacts) {
+ let _ = insert_home_event(ev)
+ }
} else if sub_id == notifications_subid {
handle_notification(ev: ev)
}