upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/25.md
diff options
context:
space:
mode:
Diffstat (limited to '25.md')
-rw-r--r--25.md19
1 files changed, 7 insertions, 12 deletions
diff --git a/25.md b/25.md
index 671c55f..72109c0 100644
--- a/25.md
+++ b/25.md
@@ -25,26 +25,21 @@ consider it a "+".
25Tags 25Tags
26---- 26----
27 27
28The reaction event SHOULD include `e` and `p` tags from the note the user is reacting to (and optionally `a` tags if the target is a replaceable event). This allows users to be notified of reactions to posts they were mentioned in. Including the `e` tags enables clients to pull all the reactions associated with individual posts or all the posts in a thread. `a` tags enables clients to seek reactions for all versions of a replaceable event. 28There MUST be always an `e` tag set to the `id` of the event that is being reacted to. The `e` tag SHOULD include a relay hint pointing to a relay where the event being reacted to can be found. If a client decides to include other `e`, which not recommended, the target event `id` should be last of the `e` tags.
29 29
30The last `e` tag MUST be the `id` of the note that is being reacted to. 30The SHOULD be a `p` tag set to the `pubkey` of the event being reacted to. If a client decides to include other `p` tags, which not recommended, the target event `pubkey` should be last the `p` tags.
31 31
32The last `p` tag MUST be the `pubkey` of the event being reacted to. 32If 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.
33 33
34The `a` tag MUST contain the coordinates (`kind:pubkey:d-tag`) of the replaceable being reacted to. 34The reaction SHOULD include a `k` tag with the stringified kind number of the reacted event as its value.
35 35
36The reaction event MAY include a `k` tag with the stringified kind number of the reacted event as its value. 36**Example code**
37
38Example code
39 37
40```swift 38```swift
41func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { 39func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent {
42 var tags: [[String]] = liked.tags.filter { 40 tags.append(["e", liked.id, liked.source_relays.first ?? ""])
43 tag in tag.count >= 2 && (tag[0] == "e" || tag[0] == "p")
44 }
45 tags.append(["e", liked.id])
46 tags.append(["p", liked.pubkey]) 41 tags.append(["p", liked.pubkey])
47 tags.append(["k", liked.kind]) 42 tags.append(["k", String(liked.kind)])
48 let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags) 43 let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags)
49 ev.calculate_id() 44 ev.calculate_id()
50 ev.sign(privkey: privkey) 45 ev.sign(privkey: privkey)