diff options
| author | Vitor Pamplona <vitor@vitorpamplona.com> | 2024-05-04 16:10:13 -0400 |
|---|---|---|
| committer | Vitor Pamplona <vitor@vitorpamplona.com> | 2024-05-04 16:10:13 -0400 |
| commit | 3834c6b60474a677b53847743212df27710e64ec (patch) | |
| tree | 5ac2d316473c073bd3fb194c50cd81aa7fbfb6db | |
| parent | dcb5d0f18d6b0c60bda9abc79c6cca99a4d86177 (diff) | |
Simplifying reactions
| -rw-r--r-- | 25.md | 14 |
1 files changed, 5 insertions, 9 deletions
| @@ -25,14 +25,13 @@ 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 | 28 | The reaction event SHOULD include `e` and `p` tags pointing to the note the user is |
| 29 | reacting to. This allows users to be notified of reactions to posts they were | 29 | reacting to. The `p` tag allows authors to be notified. The `e` tags enables clients |
| 30 | mentioned in. Including the `e` tags enables clients to pull all the reactions | 30 | to pull all the reactions to individual posts. |
| 31 | associated with individual posts or all the posts in a thread. | ||
| 32 | 31 | ||
| 33 | The last `e` tag MUST be the `id` of the note that is being reacted to. | 32 | The `e` tag MUST be the `id` of the note that is being reacted to. |
| 34 | 33 | ||
| 35 | The last `p` tag MUST be the `pubkey` of the event being reacted to. | 34 | The `p` tag MUST be the `pubkey` of the event being reacted to. |
| 36 | 35 | ||
| 37 | 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 |
| 38 | of the reacted event as its value. | 37 | of the reacted event as its value. |
| @@ -41,9 +40,6 @@ Example code | |||
| 41 | 40 | ||
| 42 | ```swift | 41 | ```swift |
| 43 | func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { | 42 | func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent { |
| 44 | var tags: [[String]] = liked.tags.filter { | ||
| 45 | tag in tag.count >= 2 && (tag[0] == "e" || tag[0] == "p") | ||
| 46 | } | ||
| 47 | tags.append(["e", liked.id]) | 43 | tags.append(["e", liked.id]) |
| 48 | tags.append(["p", liked.pubkey]) | 44 | tags.append(["p", liked.pubkey]) |
| 49 | tags.append(["k", liked.kind]) | 45 | tags.append(["k", liked.kind]) |