reply: ensure the person you're replying to is the first entry in the reply description

Suggested-by: Tanel
Changelog-Fixed: Ensure the person you're replying to is the first entry in the reply description
This commit is contained in:
William Casarin
2023-08-06 15:37:32 -07:00
parent e642913944
commit 25e022d933
5 changed files with 40 additions and 14 deletions

View File

@@ -12,16 +12,24 @@ struct ReplyDesc {
let others: Int
}
func make_reply_description(_ tags: Tags) -> ReplyDesc {
func make_reply_description(_ event: NostrEvent, replying_to: NostrEvent?) -> ReplyDesc {
var c = 0
var ns: [Pubkey] = []
var i = tags.count
var i = event.tags.count
for tag in tags {
if let replying_to {
ns.append(replying_to.pubkey)
}
for tag in event.tags {
if let pk = Pubkey.from_tag(tag: tag) {
c += 1
if ns.count < 2 {
ns.append(pk)
if let replying_to, pk == replying_to.pubkey {
continue
} else {
ns.append(pk)
}
}
}
i -= 1