From 7437199ef6b80a8b8d2fa0f12c70e198b42d4f6d Mon Sep 17 00:00:00 2001 From: William Casarin Date: Wed, 15 Jun 2022 14:43:59 -0700 Subject: [PATCH] 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 --- damus/Models/Contacts.swift | 12 ++++++++++-- damus/Models/HomeModel.swift | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/damus/Models/Contacts.swift b/damus/Models/Contacts.swift index 139f4717..09ef1be5 100644 --- 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 index d91b9e62..96f8b2d7 100644 --- 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) }