diff options
| author | Kieran <kieran@harkin.me> | 2024-10-15 11:15:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-15 11:15:54 +0100 |
| commit | 1e2f19863ca56754daa2466881eb22087a71b17d (patch) | |
| tree | 4f7be759dce290fea1d3ae10c403260b466ee16c /25.md | |
| parent | 53afaaece61f02e92b5ef9c3e9c32945c7ebf522 (diff) | |
| parent | e381b577c997b849fa544eea7dc9f08b360b4a33 (diff) | |
Merge branch 'master' into nip71-imeta
Diffstat (limited to '25.md')
| -rw-r--r-- | 25.md | 42 |
1 files changed, 30 insertions, 12 deletions
| @@ -25,24 +25,23 @@ consider it a "+". | |||
| 25 | Tags | 25 | Tags |
| 26 | ---- | 26 | ---- |
| 27 | 27 | ||
| 28 | The reaction event SHOULD include `a`, `e` and `p` tags pointing to the note the user is | 28 | The reaction event SHOULD include `e` and `p` tags from the note the user is reacting to (and optionally `a` tags if the target is a replaceable event). This allows users to be notified of reactions to posts they were mentioned in. Including the `e` tags enables clients to pull all the reactions associated with individual posts or all the posts in a thread. `a` tags enables clients to seek reactions for all versions of a replaceable event. |
| 29 | reacting to. The `p` tag allows authors to be notified. The `e` tags enables clients | ||
| 30 | to pull all the reactions to individual events and `a` tags enables clients to seek reactions | ||
| 31 | for all versions of a replaceable event. | ||
| 32 | 29 | ||
| 33 | The `e` tag MUST be the `id` of the note that is being reacted to. | 30 | The last `e` tag MUST be the `id` of the note that is being reacted to. |
| 34 | 31 | ||
| 35 | The `a` tag MUST contain the coordinates (`kind:pubkey:d-tag`) of the replaceable being reacted to. | 32 | The last `p` tag MUST be the `pubkey` of the event being reacted to. |
| 36 | 33 | ||
| 37 | The `p` tag MUST be the `pubkey` of the event being reacted to. | 34 | The `a` tag MUST contain the coordinates (`kind:pubkey:d-tag`) of the replaceable being reacted to. |
| 38 | 35 | ||
| 39 | The reaction event MAY include a `k` tag with the stringified kind number | 36 | The reaction event MAY include a `k` tag with the stringified kind number of the reacted event as its value. |
| 40 | of the reacted event as its value. | ||
| 41 | 37 | ||
| 42 | Example code | 38 | Example code |
| 43 | 39 | ||
| 44 | ```swift | 40 | ```swift |
| 45 | func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { | 41 | func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { |
| 42 | var tags: [[String]] = liked.tags.filter { | ||
| 43 | tag in tag.count >= 2 && (tag[0] == "e" || tag[0] == "p") | ||
| 44 | } | ||
| 46 | tags.append(["e", liked.id]) | 45 | tags.append(["e", liked.id]) |
| 47 | tags.append(["p", liked.pubkey]) | 46 | tags.append(["p", liked.pubkey]) |
| 48 | tags.append(["k", liked.kind]) | 47 | tags.append(["k", liked.kind]) |
| @@ -53,6 +52,26 @@ func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> Nost | |||
| 53 | } | 52 | } |
| 54 | ``` | 53 | ``` |
| 55 | 54 | ||
| 55 | Reactions to a website | ||
| 56 | --------------------- | ||
| 57 | |||
| 58 | 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. | ||
| 59 | |||
| 60 | ```jsonc | ||
| 61 | { | ||
| 62 | "kind": 17, | ||
| 63 | "content": "⭐", | ||
| 64 | "tags": [ | ||
| 65 | ["r", "https://example.com/"] | ||
| 66 | ], | ||
| 67 | // other fields... | ||
| 68 | } | ||
| 69 | ``` | ||
| 70 | |||
| 71 | 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. | ||
| 72 | A fragment MAY be attached to the URL, to react to a section of the page. | ||
| 73 | It should be noted that a URL with a fragment is not considered to be the same URL as the original. | ||
| 74 | |||
| 56 | Custom Emoji Reaction | 75 | Custom Emoji Reaction |
| 57 | --------------------- | 76 | --------------------- |
| 58 | 77 | ||
| @@ -60,15 +79,14 @@ The client may specify a custom emoji ([NIP-30](30.md)) `:shortcode:` in the | |||
| 60 | reaction content. The client should refer to the emoji tag and render the | 79 | reaction content. The client should refer to the emoji tag and render the |
| 61 | content as an emoji if shortcode is specified. | 80 | content as an emoji if shortcode is specified. |
| 62 | 81 | ||
| 63 | ```json | 82 | ```jsonc |
| 64 | { | 83 | { |
| 65 | "kind": 7, | 84 | "kind": 7, |
| 66 | "content": ":soapbox:", | 85 | "content": ":soapbox:", |
| 67 | "tags": [ | 86 | "tags": [ |
| 68 | ["emoji", "soapbox", "https://gleasonator.com/emoji/Gleasonator/soapbox.png"] | 87 | ["emoji", "soapbox", "https://gleasonator.com/emoji/Gleasonator/soapbox.png"] |
| 69 | ], | 88 | ], |
| 70 | "pubkey": "79c2cae114ea28a981e7559b4fe7854a473521a8d22a66bbab9fa248eb820ff6", | 89 | // other fields... |
| 71 | "created_at": 1682790000 | ||
| 72 | } | 90 | } |
| 73 | ``` | 91 | ``` |
| 74 | 92 | ||