diff options
| author | Alex Gleason <alex@alexgleason.me> | 2026-04-10 13:31:37 -0500 |
|---|---|---|
| committer | Alex Gleason <alex@alexgleason.me> | 2026-04-10 13:31:37 -0500 |
| commit | 5e1e24766910fc07cb61a049aed2623987458ec2 (patch) | |
| tree | b7588f61fddf9374268d5cd6f4e3f2655d7c840a /25.md | |
| parent | b8782df594b4e7e8f088869134908eed58be6078 (diff) | |
| parent | 3465f540e3eaedccb5309711b502f0febf56b52f (diff) | |
Merge nip44-big-payloads into bigger-nip44bigger-nip44
Diffstat (limited to '25.md')
| -rw-r--r-- | 25.md | 60 |
1 files changed, 36 insertions, 24 deletions
| @@ -7,38 +7,36 @@ Reactions | |||
| 7 | 7 | ||
| 8 | `draft` `optional` | 8 | `draft` `optional` |
| 9 | 9 | ||
| 10 | A reaction is a `kind 7` event that is used to react to other events. | 10 | A reaction is a `kind 7` event that is used to indicate user reactions to other events. A |
| 11 | reaction's `content` field MUST include user-generated-content indicating the value of the | ||
| 12 | reaction (conventionally `+`, `-`, or an emoji). | ||
| 11 | 13 | ||
| 12 | The generic reaction, represented by the `content` set to a `+` string, SHOULD | 14 | A reaction with `content` set to `+` or an empty string MUST be interpreted as a "like" or "upvote". |
| 13 | be interpreted as a "like" or "upvote". | 15 | A reaction with `content` set to `-` MUST be interpreted as a "dislike" or "downvote". |
| 14 | 16 | ||
| 15 | A reaction with `content` set to `-` SHOULD be interpreted as a "dislike" or | 17 | A 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 | 18 | as a "like" or "dislike". Clients MAY instead display this emoji reaction on the post. |
| 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 tallies. | ||
| 20 | |||
| 21 | The `content` MAY be an emoji, or [NIP-30](30.md) custom emoji in this case it MAY be interpreted as a "like" or "dislike", | ||
| 22 | or the client MAY display this emoji reaction on the post. If the `content` is an empty string then the client should | ||
| 23 | consider it a "+". | ||
| 24 | 19 | ||
| 25 | Tags | 20 | Tags |
| 26 | ---- | 21 | ---- |
| 27 | 22 | ||
| 28 | There 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. | 23 | There 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 | ||
| 30 | The 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. | 25 | There 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 | ||
| 32 | If 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. | 27 | If 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 | ||
| 34 | The reaction SHOULD include a `k` tag with the stringified kind number of the reacted event as its value. | 29 | The `e` and `a` tags SHOULD include relay and pubkey hints. The `p` tags SHOULD include relay hints. |
| 30 | |||
| 31 | The 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 |
| 39 | func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { | 36 | func 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 | ||
| 50 | Reactions to a website | 48 | External Content Reactions |
| 51 | --------------------- | 49 | --------------------- |
| 52 | 50 | ||
| 53 | If 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. | 51 | If 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 | ||
| 66 | URLs 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:_ |
| 67 | A fragment MAY be attached to the URL, to react to a section of the page. | 66 | ```jsonc |
| 68 | It 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 | ||
| 70 | Custom Emoji Reaction | 82 | Custom Emoji Reaction |
| 71 | --------------------- | 83 | --------------------- |