diff options
| author | fiatjaf_ <fiatjaf@gmail.com> | 2025-02-26 17:06:35 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-26 17:06:35 -0300 |
| commit | 1e8b1bb16b4e449dadda0b3d82b031b182780cbb (patch) | |
| tree | c93d40e89c63d15556ed05eff7d132e7f75339b2 | |
| parent | 7cc120ecb01963e37f9adcd3b57b8efc1dd9e828 (diff) | |
nip25: recommend that reactions do not include a million tags (#1811)
| -rw-r--r-- | 25.md | 19 |
1 files changed, 7 insertions, 12 deletions
| @@ -25,26 +25,21 @@ consider it a "+". | |||
| 25 | Tags | 25 | Tags |
| 26 | ---- | 26 | ---- |
| 27 | 27 | ||
| 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. | 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. |
| 29 | 29 | ||
| 30 | The last `e` tag MUST be the `id` of the note that is being reacted to. | 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. |
| 31 | 31 | ||
| 32 | The last `p` tag MUST be the `pubkey` of the event being reacted to. | 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. |
| 33 | 33 | ||
| 34 | The `a` tag MUST contain the coordinates (`kind:pubkey:d-tag`) of the replaceable being reacted to. | 34 | The reaction SHOULD include a `k` tag with the stringified kind number of the reacted event as its value. |
| 35 | 35 | ||
| 36 | The reaction event MAY include a `k` tag with the stringified kind number of the reacted event as its value. | 36 | **Example code** |
| 37 | |||
| 38 | Example code | ||
| 39 | 37 | ||
| 40 | ```swift | 38 | ```swift |
| 41 | func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { | 39 | func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { |
| 42 | var tags: [[String]] = liked.tags.filter { | 40 | tags.append(["e", liked.id, liked.source_relays.first ?? ""]) |
| 43 | tag in tag.count >= 2 && (tag[0] == "e" || tag[0] == "p") | ||
| 44 | } | ||
| 45 | tags.append(["e", liked.id]) | ||
| 46 | tags.append(["p", liked.pubkey]) | 41 | tags.append(["p", liked.pubkey]) |
| 47 | tags.append(["k", liked.kind]) | 42 | tags.append(["k", String(liked.kind)]) |
| 48 | let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags) | 43 | let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags) |
| 49 | ev.calculate_id() | 44 | ev.calculate_id() |
| 50 | ev.sign(privkey: privkey) | 45 | ev.sign(privkey: privkey) |