1
0
mirror of git://jb55.com/damus synced 2024-09-29 16:30:44 +00:00

nip10: be nicer to deprecated nip10

to ease the transition, let's not add more than 2 etags or deprecated
nip10 gets confused

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin 2024-05-09 15:17:01 -07:00
parent 23138c5e03
commit 13a7ee82d0
2 changed files with 6 additions and 3 deletions

View File

@ -624,15 +624,18 @@ func nip10_reply_tags(replying_to: NostrEvent, keypair: Keypair) -> [[String]] {
// otherwise use the root tag from the parent's nip10 reply and include the note
// that we are replying to's note id.
var tags = [
let tags = [
["e", nip10.root.note_id.hex(), nip10.root.relay ?? "", "root"],
["e", replying_to.id.hex(), "", "reply"]
]
// we also add the parent's nip10 reply tag as an additional e tag for context
/* this is incorrect for deprecated nip 10, let's just not add it for now
if let reply = nip10.reply {
tags.append(["e", reply.note_id.hex(), reply.relay ?? ""])
}
*/
return tags
}

View File

@ -184,7 +184,7 @@ final class NIP10Tests: XCTestCase {
let replying_to_hex = "a8dc8b74852d7ad114d5d650b2125459c0cba3c1fdcaaf527e03f24082e11ab3"
let pk = Pubkey(hex: "5b0183ab6c3e322bf4d41c6b3aef98562a144847b7499543727c5539a114563e")!
let last_reply_hex = "1bb940ce0ba0d4a3b2a589355d908498dcd7452f941cf520072218f7e6ede75e"
//let last_reply_hex = "1bb940ce0ba0d4a3b2a589355d908498dcd7452f941cf520072218f7e6ede75e"
let note = decode_nostr_event_json(json: note_json)!
let reply = build_post(state: test_damus_state, post: .init(string: "hello"), action: .replying_to(note), uploadedMedias: [], pubkeys: [pk] + note.referenced_pubkeys.map({pk in pk}))
let root_hex = "00152d2945459fb394fed2ea95af879c903c4ec42d96327a739fa27c023f20e0"
@ -193,7 +193,7 @@ final class NIP10Tests: XCTestCase {
[
["e", root_hex, "wss://nostr.mutinywallet.com/", "root"],
["e", replying_to_hex, "", "reply"],
["e", last_reply_hex, "wss://relay.nostrplebs.com"],
//["e", last_reply_hex, "wss://relay.nostrplebs.com"],
["p", "5b0183ab6c3e322bf4d41c6b3aef98562a144847b7499543727c5539a114563e"],
["p", "6e75f7972397ca3295e0f4ca0fbc6eb9cc79be85bafdd56bd378220ca8eee74e"],
])