diff options
| author | Jeff Thibault <jdthibault2@gmail.com> | 2022-08-13 10:03:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-13 10:03:37 -0400 |
| commit | a902083bac9b95ec1ed9e4e1dc1d018b4a7f2696 (patch) | |
| tree | fb4e6124971c8b012326ec52e6f0cf58e94779ff /25.md | |
| parent | d1b6bdb18e522fa34ff7cfec3d56318da596fdff (diff) | |
| parent | 7fe572ec5a7321726c9469f70a93bb278be8d774 (diff) | |
Merge branch 'nostr-protocol:master' into nip22-unacceptable-event-time
Diffstat (limited to '25.md')
| -rw-r--r-- | 25.md | 49 |
1 files changed, 49 insertions, 0 deletions
| @@ -0,0 +1,49 @@ | |||
| 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 the `content` set to a `+` string, SHOULD | ||
| 13 | be interpreted as a "like" or "upvote". | ||
| 14 | |||
| 15 | A reaction with `content` set to `-` SHOULD be interepreted as a "dislike" or | ||
| 16 | "downvote". It SHOULD NOT be counted as a "like", and MAY be displayed as a | ||
| 17 | downvote or dislike on a post. A client MAY also choose to tally likes against | ||
| 18 | dislikes in a reddit-like system of upvotes and downvotes, or display them as | ||
| 19 | separate tallys. | ||
| 20 | |||
| 21 | The `content` MAY be an emoji, in this case it MAY be interpreted as a "like", | ||
| 22 | or the client MAY display this emoji reaction on the post. | ||
| 23 | |||
| 24 | Tags | ||
| 25 | ---- | ||
| 26 | |||
| 27 | The reaction event SHOULD include `e` and `p` tags from the note the user is | ||
| 28 | reacting to. This allows users to be notified of reactions to posts they were | ||
| 29 | mentioned in. Including the `e` tags enables clients to pull all the reactions | ||
| 30 | associated with individual posts or all the posts in a thread. | ||
| 31 | |||
| 32 | The last `e` tag MUST be the `id` of the note that is being reacted to. | ||
| 33 | |||
| 34 | The last `p` tag MUST be the `pubkey` of the event being reacted to. | ||
| 35 | |||
| 36 | Example code | ||
| 37 | |||
| 38 | ```swift | ||
| 39 | func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { | ||
| 40 | var tags: [[String]] = liked.tags.filter { | ||
| 41 | tag in tag.count >= 2 && (tag[0] == "e" || tag[0] == "p") | ||
| 42 | } | ||
| 43 | tags.append(["e", liked.id]) | ||
| 44 | tags.append(["p", liked.pubkey]) | ||
| 45 | let ev = NostrEvent(content: "", pubkey: pubkey, kind: 7, tags: tags) | ||
| 46 | ev.calculate_id() | ||
| 47 | ev.sign(privkey: privkey) | ||
| 48 | return ev | ||
| 49 | } | ||