diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift index 45798274..7bfd8877 100644 --- a/damus/Nostr/NostrEvent.swift +++ b/damus/Nostr/NostrEvent.swift @@ -720,11 +720,26 @@ func make_zap_request_event(keypair: FullKeypair, content: String, relays: [Rela return ev } +func uniq(_ xs: [T]) -> [T] { + var s = Set() + var ys: [T] = [] + + for x in xs { + if s.contains(x) { + continue + } + s.insert(x) + ys.append(x) + } + + return ys +} + func gather_reply_ids(our_pubkey: String, from: NostrEvent) -> [ReferencedId] { var ids = get_referenced_ids(tags: from.tags, key: "e").first.map { [$0] } ?? [] ids.append(ReferencedId(ref_id: from.id, relay_id: nil, key: "e")) - ids.append(contentsOf: Set(from.referenced_pubkeys.filter { $0.ref_id != our_pubkey })) + ids.append(contentsOf: uniq(from.referenced_pubkeys.filter { $0.ref_id != our_pubkey })) if from.pubkey != our_pubkey { ids.append(ReferencedId(ref_id: from.pubkey, relay_id: nil, key: "p")) }