diff options
| author | William Casarin <jb55@jb55.com> | 2022-07-30 09:34:04 -0700 |
|---|---|---|
| committer | William Casarin <jb55@jb55.com> | 2022-07-30 09:50:26 -0700 |
| commit | dcbd504639d20d1b0ae6bb837609710645781b88 (patch) | |
| tree | 0f74c51110cc45a3bbfa6186ff1b2d8b6f60e998 /25.md | |
| parent | f2cc7bd86f04c302b610ebdca3b087b22694dc2e (diff) | |
NIP-25: Reactions
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat (limited to '25.md')
| -rw-r--r-- | 25.md | 43 |
1 files changed, 43 insertions, 0 deletions
| @@ -0,0 +1,43 @@ | |||
| 1 | |||
| 2 | NIP-25 | ||
| 3 | ====== | ||
| 4 | |||
| 5 | Reactions | ||
| 6 | --------- | ||
| 7 | |||
| 8 | `draft` `optional` `author:jb55` | ||
| 9 | |||
| 10 | A reaction is a `kind 7` note that is used to react to `kind 1` text notes. | ||
| 11 | |||
| 12 | The generic reaction, represented by an empty string, SHOULD be interpreted as | ||
| 13 | a "like". | ||
| 14 | |||
| 15 | The `content` MAY be an emoji, in this case it MAY be interpreted as a "like", | ||
| 16 | or the client MAY display this emoji reaction on the post. | ||
| 17 | |||
| 18 | Tags | ||
| 19 | ---- | ||
| 20 | |||
| 21 | The reaction event SHOULD include `e` and `p` tags from the note the user is | ||
| 22 | reacting to. This allows users to be notified of reactions to posts they were | ||
| 23 | mentioned in. Including the `e` tags enables clients to pull all the reactions | ||
| 24 | associated with individual posts or all the posts in a thread. | ||
| 25 | |||
| 26 | The last `e` tag MUST be the `id` of the note that is being reacted to. | ||
| 27 | |||
| 28 | The last `p` tag MUST be the `pubkey` of the event being reacted to. | ||
| 29 | |||
| 30 | Example code | ||
| 31 | |||
| 32 | ```swift | ||
| 33 | func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { | ||
| 34 | var tags: [[String]] = liked.tags.filter { | ||
| 35 | tag in tag.count >= 2 && (tag[0] == "e" || tag[0] == "p") | ||
| 36 | } | ||
| 37 | tags.append(["e", liked.id]) | ||
| 38 | tags.append(["p", liked.pubkey]) | ||
| 39 | let ev = NostrEvent(content: "", pubkey: pubkey, kind: 7, tags: tags) | ||
| 40 | ev.calculate_id() | ||
| 41 | ev.sign(privkey: privkey) | ||
| 42 | return ev | ||
| 43 | } | ||