From a2eb77a5e961b4ee4ce98371bb9f3a490937e0fa Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sun, 5 Feb 2023 10:49:51 -0800 Subject: [PATCH] Hide incoming dms from blocked users Changelog-Fixed: Hide incoming DMs from blocked users --- damus/Models/HomeModel.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift index a0fe896a..c3989a96 100644 --- a/damus/Models/HomeModel.swift +++ b/damus/Models/HomeModel.swift @@ -476,7 +476,7 @@ class HomeModel: ObservableObject { } func handle_dm(_ ev: NostrEvent) { - if let notifs = handle_incoming_dm(prev_events: self.new_events, dms: self.dms, our_pubkey: self.damus_state.pubkey, ev: ev) { + if let notifs = handle_incoming_dm(contacts: damus_state.contacts, prev_events: self.new_events, dms: self.dms, our_pubkey: self.damus_state.pubkey, ev: ev) { self.new_events = notifs } } @@ -707,7 +707,12 @@ func load_our_relays(contacts: Contacts, our_pubkey: String, pool: RelayPool, m_ } } -func handle_incoming_dm(prev_events: NewEventsBits, dms: DirectMessagesModel, our_pubkey: String, ev: NostrEvent) -> NewEventsBits? { +func handle_incoming_dm(contacts: Contacts, prev_events: NewEventsBits, dms: DirectMessagesModel, our_pubkey: String, ev: NostrEvent) -> NewEventsBits? { + // hide blocked users + guard should_show_event(contacts: contacts, ev: ev) else { + return prev_events + } + var inserted = false var found = false let ours = ev.pubkey == our_pubkey