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.md60
1 files changed, 36 insertions, 24 deletions
diff --git a/25.md b/25.md
index 72109c0..7ac4fb1 100644
--- a/25.md
+++ b/25.md
@@ -7,38 +7,36 @@ Reactions
7 7
8`draft` `optional` 8`draft` `optional`
9 9
10A reaction is a `kind 7` event that is used to react to other events. 10A reaction is a `kind 7` event that is used to indicate user reactions to other events. A
11reaction's `content` field MUST include user-generated-content indicating the value of the
12reaction (conventionally `+`, `-`, or an emoji).
11 13
12The generic reaction, represented by the `content` set to a `+` string, SHOULD 14A reaction with `content` set to `+` or an empty string MUST be interpreted as a "like" or "upvote".
13be interpreted as a "like" or "upvote". 15A reaction with `content` set to `-` MUST be interpreted as a "dislike" or "downvote".
14 16
15A reaction with `content` set to `-` SHOULD be interpreted as a "dislike" or 17A reaction with `content` set to an emoji or [NIP-30](30.md) custom emoji SHOULD NOT be interpreted
16"downvote". It SHOULD NOT be counted as a "like", and MAY be displayed as a 18as a "like" or "dislike". Clients MAY instead display this emoji reaction on the post.
17downvote or dislike on a post. A client MAY also choose to tally likes against
18dislikes in a reddit-like system of upvotes and downvotes, or display them as
19separate tallies.
20
21The `content` MAY be an emoji, or [NIP-30](30.md) custom emoji in this case it MAY be interpreted as a "like" or "dislike",
22or the client MAY display this emoji reaction on the post. If the `content` is an empty string then the client should
23consider it a "+".
24 19
25Tags 20Tags
26---- 21----
27 22
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. 23There 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 24
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. 25There 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 26
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. 27If 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 28
34The reaction SHOULD include a `k` tag with the stringified kind number of the reacted event as its value. 29The `e` and `a` tags SHOULD include relay and pubkey hints. The `p` tags SHOULD include relay hints.
30
31The reaction event MAY include a `k` tag with the stringified kind number of the reacted event as its value.
35 32
36**Example code** 33**Example code**
37 34
38```swift 35```swift
39func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { 36func make_like_event(pubkey: String, privkey: String, liked: NostrEvent, hint: String) -> NostrEvent {
40 tags.append(["e", liked.id, liked.source_relays.first ?? ""]) 37 var tags: [[String]] = []
41 tags.append(["p", liked.pubkey]) 38 tags.append(["e", liked.id, hint, liked.pubkey])
39 tags.append(["p", liked.pubkey, hint])
42 tags.append(["k", String(liked.kind)]) 40 tags.append(["k", String(liked.kind)])
43 let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags) 41 let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags)
44 ev.calculate_id() 42 ev.calculate_id()
@@ -47,25 +45,39 @@ func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> Nost
47} 45}
48``` 46```
49 47
50Reactions to a website 48External Content Reactions
51--------------------- 49---------------------
52 50
53If the target of the reaction is a website, the reaction MUST be a `kind 17` event and MUST include an `r` tag with the website's URL. 51If the target of a reaction is not a native nostr event, the reaction MUST be a `kind 17` event and MUST include [NIP-73](73.md) external content `k` + `i` tags to properly reference the content.
54 52
53_Reacting to a website:_
55```jsonc 54```jsonc
56{ 55{
57 "kind": 17, 56 "kind": 17,
58 "content": "⭐", 57 "content": "⭐",
59 "tags": [ 58 "tags": [
60 ["r", "https://example.com/"] 59 ["k", "web"],
60 ["i", "https://example.com"]
61 ], 61 ],
62 // other fields...
63} 62}
64``` 63```
65 64
66URLs SHOULD be [normalized](https://datatracker.ietf.org/doc/html/rfc3986#section-6), so that reactions to the same website are not omitted from queries. 65_Reacting to a podcast episode:_
67A fragment MAY be attached to the URL, to react to a section of the page. 66```jsonc
68It should be noted that a URL with a fragment is not considered to be the same URL as the original. 67{
68 "kind": 17,
69 "content": "+",
70 "tags": [
71 ["k", "podcast:guid"],
72 ["i", "podcast:guid:917393e3-1b1e-5cef-ace4-edaa54e1f810", "https://fountain.fm/show/QRT0l2EfrKXNGDlRrmjL"],
73 ["k", "podcast:item:guid"],
74 ["i", "podcast:item:guid:PC20-229", "https://fountain.fm/episode/DQqBg5sD3qFGMCZoSuLF"]
75 ],
76}
77```
78
79
80
69 81
70Custom Emoji Reaction 82Custom Emoji Reaction
71--------------------- 83---------------------