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:
authorSemisol <45574030+Semisol@users.noreply.github.com>2023-11-19 01:45:41 +0100
committerGitHub <noreply@github.com>2023-11-19 01:45:41 +0100
commitda19c078ab892b578a5c35968443205c9e8ac27f (patch)
tree17a9f4f3105acdae234d3bc67e42571aed261fa2 /25.md
parent4d709d1804de45bab3739ce814d4b0c0b211c273 (diff)
parent5dcfe85306434f21ecb1e7a47edd92b2e3e64f9a (diff)
Merge branch 'master' into clarify-json-serialization
Diffstat (limited to '25.md')
-rw-r--r--25.md35
1 files changed, 31 insertions, 4 deletions
diff --git a/25.md b/25.md
index f74bcc0..3b4aa59 100644
--- a/25.md
+++ b/25.md
@@ -5,9 +5,9 @@ NIP-25
5Reactions 5Reactions
6--------- 6---------
7 7
8`draft` `optional` `author:jb55` 8`draft` `optional`
9 9
10A reaction is a `kind 7` note that is used to react to other notes. 10A reaction is a `kind 7` event that is used to react to other events.
11 11
12The generic reaction, represented by the `content` set to a `+` string, SHOULD 12The generic reaction, represented by the `content` set to a `+` string, SHOULD
13be interpreted as a "like" or "upvote". 13be interpreted as a "like" or "upvote".
@@ -18,8 +18,9 @@ downvote 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 18dislikes in a reddit-like system of upvotes and downvotes, or display them as
19separate tallies. 19separate tallies.
20 20
21The `content` MAY be an emoji, in this case it MAY be interpreted as a "like" or "dislike", 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. 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 "+".
23 24
24Tags 25Tags
25---- 26----
@@ -33,6 +34,9 @@ The last `e` tag MUST be the `id` of the note that is being reacted to.
33 34
34The last `p` tag MUST be the `pubkey` of the event being reacted to. 35The last `p` tag MUST be the `pubkey` of the event being reacted to.
35 36
37The reaction event MAY include a `k` tag with the stringified kind number
38of the reacted event as its value.
39
36Example code 40Example code
37 41
38```swift 42```swift
@@ -42,8 +46,31 @@ func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> Nost
42 } 46 }
43 tags.append(["e", liked.id]) 47 tags.append(["e", liked.id])
44 tags.append(["p", liked.pubkey]) 48 tags.append(["p", liked.pubkey])
49 tags.append(["k", liked.kind])
45 let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags) 50 let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags)
46 ev.calculate_id() 51 ev.calculate_id()
47 ev.sign(privkey: privkey) 52 ev.sign(privkey: privkey)
48 return ev 53 return ev
49} 54}
55```
56
57Custom Emoji Reaction
58---------------------
59
60The client may specify a custom emoji ([NIP-30](30.md)) `:shortcode:` in the
61reaction content. The client should refer to the emoji tag and render the
62content as an emoji if shortcode is specified.
63
64```json
65{
66 "kind": 7,
67 "content": ":soapbox:",
68 "tags": [
69 ["emoji", "soapbox", "https://gleasonator.com/emoji/Gleasonator/soapbox.png"]
70 ],
71 "pubkey": "79c2cae114ea28a981e7559b4fe7854a473521a8d22a66bbab9fa248eb820ff6",
72 "created_at": 1682790000
73}
74```
75
76The content can be set only one `:shortcode:`. And emoji tag should be one.