Reply.swift (786B)
1 // 2 // Reply.swift 3 // damus 4 // 5 // Created by William Casarin on 2022-05-08. 6 // 7 8 import Foundation 9 10 struct ReplyDesc { 11 let pubkeys: [Pubkey] 12 let others: Int 13 } 14 15 func make_reply_description(_ event: NostrEvent, replying_to: NostrEvent?) -> ReplyDesc { 16 var c = 0 17 var ns: [Pubkey] = [] 18 var i = event.tags.count 19 20 if let replying_to { 21 ns.append(replying_to.pubkey) 22 } 23 24 for tag in event.tags { 25 if let pk = Pubkey.from_tag(tag: tag) { 26 c += 1 27 if ns.count < 2 { 28 if let replying_to, pk == replying_to.pubkey { 29 continue 30 } else { 31 ns.append(pk) 32 } 33 } 34 } 35 i -= 1 36 } 37 38 return ReplyDesc(pubkeys: ns, others: c) 39 }