generalize is_friend_event even further
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -340,7 +340,7 @@ struct ContentView: View {
|
||||
}
|
||||
|
||||
func is_friend_event(_ ev: NostrEvent) -> Bool {
|
||||
return damus.is_friend_event(ev, our_pubkey: self.pubkey, contacts: self.damus_state!.contacts)
|
||||
return damus.is_friend_event(ev, our_pubkey: self.pubkey, friends: self.damus_state!.contacts.friends)
|
||||
}
|
||||
|
||||
func switch_timeline(_ timeline: Timeline) {
|
||||
@@ -775,28 +775,3 @@ func update_filters_with_since(last_of_kind: [Int: NostrEvent], filters: [NostrF
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func is_friend_event(_ ev: NostrEvent, our_pubkey: String, contacts: Contacts) -> Bool
|
||||
{
|
||||
if ev.pubkey == our_pubkey {
|
||||
return true
|
||||
}
|
||||
|
||||
if contacts.is_friend(ev.pubkey) {
|
||||
return true
|
||||
}
|
||||
|
||||
if ev.is_reply {
|
||||
// show our replies?
|
||||
if ev.pubkey == our_pubkey {
|
||||
return true
|
||||
}
|
||||
for pk in ev.referenced_pubkeys {
|
||||
if contacts.is_friend(pk.ref_id) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -120,3 +120,28 @@ func make_contact_relays(_ relays: [RelayDescriptor]) -> [String: RelayInfo] {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func is_friend_event(_ ev: NostrEvent, our_pubkey: String, friends: Set<String>) -> Bool
|
||||
{
|
||||
if ev.pubkey == our_pubkey {
|
||||
return true
|
||||
}
|
||||
|
||||
if friends.contains(ev.pubkey) {
|
||||
return true
|
||||
}
|
||||
|
||||
if ev.is_reply {
|
||||
// show our replies?
|
||||
if ev.pubkey == our_pubkey {
|
||||
return true
|
||||
}
|
||||
for pk in ev.referenced_pubkeys {
|
||||
if friends.contains(pk.ref_id) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user