2023-04-17 12:31:18 -04:00
|
|
|
# NIP-25
|
2022-07-30 12:34:04 -04:00
|
|
|
|
2023-04-17 12:31:18 -04:00
|
|
|
## Reactions
|
2022-07-30 12:34:04 -04:00
|
|
|
|
|
|
|
`draft` `optional` `author:jb55`
|
|
|
|
|
2022-08-19 18:17:54 -04:00
|
|
|
A reaction is a `kind 7` note that is used to react to other notes.
|
2022-07-30 12:34:04 -04:00
|
|
|
|
2022-07-31 15:44:40 -04:00
|
|
|
The generic reaction, represented by the `content` set to a `+` string, SHOULD
|
|
|
|
be interpreted as a "like" or "upvote".
|
2022-07-30 12:34:04 -04:00
|
|
|
|
2023-01-01 02:15:08 -05:00
|
|
|
A reaction with `content` set to `-` SHOULD be interpreted as a "dislike" or
|
2022-07-30 13:09:33 -04:00
|
|
|
"downvote". It SHOULD NOT be counted as a "like", and MAY be displayed as a
|
|
|
|
downvote or dislike on a post. A client MAY also choose to tally likes against
|
|
|
|
dislikes in a reddit-like system of upvotes and downvotes, or display them as
|
2023-04-07 08:08:03 -04:00
|
|
|
separate tallies.
|
2022-07-30 13:09:33 -04:00
|
|
|
|
2023-01-11 15:26:31 -05:00
|
|
|
The `content` MAY be an emoji, in this case it MAY be interpreted as a "like" or "dislike",
|
2022-07-30 12:34:04 -04:00
|
|
|
or the client MAY display this emoji reaction on the post.
|
|
|
|
|
2023-04-17 12:31:18 -04:00
|
|
|
## Tags
|
2022-07-30 12:34:04 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2023-04-17 12:31:18 -04:00
|
|
|
The last `e` tag MUST be the `id` of the note that is being reacted to.
|
2022-07-30 12:34:04 -04:00
|
|
|
|
|
|
|
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 {
|
2023-04-17 12:31:18 -04:00
|
|
|
tag in tag.count >= 2 && (tag[0] == "e" || tag[0] == "p")
|
2022-07-30 12:34:04 -04:00
|
|
|
}
|
|
|
|
tags.append(["e", liked.id])
|
|
|
|
tags.append(["p", liked.pubkey])
|
2022-10-30 11:34:14 -04:00
|
|
|
let ev = NostrEvent(content: "+", pubkey: pubkey, kind: 7, tags: tags)
|
2022-07-30 12:34:04 -04:00
|
|
|
ev.calculate_id()
|
|
|
|
ev.sign(privkey: privkey)
|
|
|
|
return ev
|
|
|
|
}
|