fix is_friend_reply

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-05-21 21:32:52 -07:00
parent e50c8f0dbc
commit b230d430ee

View File

@@ -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<String>) -> 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