recommend using "k" tag always.

This commit is contained in:
fiatjaf 2025-02-26 17:04:45 -03:00
parent 1b86a40df4
commit 23b069d469

6
25.md
View File

@ -31,7 +31,7 @@ The SHOULD be a `p` tag set to the `pubkey` of the event being reacted to. If a
If the event being reacted to is an addressable event, an `a` SHOULD be included together with the `e` tag, it must be set to the coordinates (`kind:pubkey:d-tag`) of the event being reacted to. If the event being reacted to is an addressable event, an `a` SHOULD be included together with the `e` tag, it must be set to the coordinates (`kind:pubkey:d-tag`) of the event being reacted to.
If the target event is not a `kind:1`, then the reaction MAY include a `k` tag with the stringified kind number of the reacted event as its value. The reaction SHOULD include a `k` tag with the stringified kind number of the reacted event as its value.
**Example code** **Example code**
@ -39,9 +39,7 @@ If the target event is not a `kind:1`, then the reaction MAY include a `k` tag w
func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent {
tags.append(["e", liked.id, liked.source_relays.first ?? ""]) tags.append(["e", liked.id, liked.source_relays.first ?? ""])
tags.append(["p", liked.pubkey]) tags.append(["p", liked.pubkey])
if liked.kind != 1 { tags.append(["k", String(liked.kind)])
tags.append(["k", liked.kind])
}
let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags) let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags)
ev.calculate_id() ev.calculate_id()
ev.sign(privkey: privkey) ev.sign(privkey: privkey)