mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-12-22 16:35:52 -05:00
NIP-25: Reactions
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
f2cc7bd86f
commit
dcbd504639
43
25.md
Normal file
43
25.md
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
NIP-25
|
||||||
|
======
|
||||||
|
|
||||||
|
Reactions
|
||||||
|
---------
|
||||||
|
|
||||||
|
`draft` `optional` `author:jb55`
|
||||||
|
|
||||||
|
A reaction is a `kind 7` note that is used to react to `kind 1` text notes.
|
||||||
|
|
||||||
|
The generic reaction, represented by an empty string, SHOULD be interpreted as
|
||||||
|
a "like".
|
||||||
|
|
||||||
|
The `content` MAY be an emoji, in this case it MAY be interpreted as a "like",
|
||||||
|
or the client MAY display this emoji reaction on the post.
|
||||||
|
|
||||||
|
Tags
|
||||||
|
----
|
||||||
|
|
||||||
|
The reaction event SHOULD include `e` and `p` tags from the note the user is
|
||||||
|
reacting to. 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.
|
||||||
|
|
||||||
|
The last `e` tag MUST be the `id` of the note that is being reacted to.
|
||||||
|
|
||||||
|
The last `p` tag MUST be the `pubkey` of the event being reacted to.
|
||||||
|
|
||||||
|
Example code
|
||||||
|
|
||||||
|
```swift
|
||||||
|
func make_like_event(pubkey: String, privkey: String, liked: NostrEvent) -> NostrEvent {
|
||||||
|
var tags: [[String]] = liked.tags.filter {
|
||||||
|
tag in tag.count >= 2 && (tag[0] == "e" || tag[0] == "p")
|
||||||
|
}
|
||||||
|
tags.append(["e", liked.id])
|
||||||
|
tags.append(["p", liked.pubkey])
|
||||||
|
let ev = NostrEvent(content: "", pubkey: pubkey, kind: 7, tags: tags)
|
||||||
|
ev.calculate_id()
|
||||||
|
ev.sign(privkey: privkey)
|
||||||
|
return ev
|
||||||
|
}
|
|
@ -18,6 +18,7 @@ NIPs stand for **Nostr Implementation Possibilities**. They exist to document wh
|
||||||
- [NIP-14: Subject tag in text events.](14.md)
|
- [NIP-14: Subject tag in text events.](14.md)
|
||||||
- [NIP-15: End of Stored Events Notice](15.md)
|
- [NIP-15: End of Stored Events Notice](15.md)
|
||||||
- [NIP-16: Event Treatment](16.md)
|
- [NIP-16: Event Treatment](16.md)
|
||||||
|
- [NIP-25: Reactions](25.md)
|
||||||
|
|
||||||
## Event Kinds
|
## Event Kinds
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ NIPs stand for **Nostr Implementation Possibilities**. They exist to document wh
|
||||||
| 3 | Contacts | 2 |
|
| 3 | Contacts | 2 |
|
||||||
| 4 | Encrypted Direct Messages | 4 |
|
| 4 | Encrypted Direct Messages | 4 |
|
||||||
| 5 | Event Deletion | 9 |
|
| 5 | Event Deletion | 9 |
|
||||||
|
| 7 | Reaction | 25 |
|
||||||
|
|
||||||
Please update this list when proposing NIPs introducing new event kinds.
|
Please update this list when proposing NIPs introducing new event kinds.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user