From b230d430ee7776e54285bf8dfe5dab0e8810718b Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sat, 21 May 2022 21:32:52 -0700 Subject: [PATCH] fix is_friend_reply Signed-off-by: William Casarin --- damus/Models/Contacts.swift | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/damus/Models/Contacts.swift b/damus/Models/Contacts.swift index 94c6bd91..3772d5f8 100644 --- a/damus/Models/Contacts.swift +++ b/damus/Models/Contacts.swift @@ -120,27 +120,22 @@ func make_contact_relays(_ relays: [RelayDescriptor]) -> [String: RelayInfo] { } } - +// TODO: tests for this func is_friend_event(_ ev: NostrEvent, our_pubkey: String, friends: Set) -> Bool { - if ev.pubkey == our_pubkey { + if !friends.contains(ev.pubkey) { + return false + } + + if !ev.is_reply { return true } - if friends.contains(ev.pubkey) { - return true - } - - if ev.is_reply { - // show our replies? - if ev.pubkey == our_pubkey { + // show our replies? + for pk in ev.referenced_pubkeys { + if friends.contains(pk.ref_id) { return true } - for pk in ev.referenced_pubkeys { - if friends.contains(pk.ref_id) { - return true - } - } } return false