From dcbd504639d20d1b0ae6bb837609710645781b88 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sat, 30 Jul 2022 09:34:04 -0700 Subject: [PATCH 1/3] NIP-25: Reactions Signed-off-by: William Casarin --- 25.md | 43 +++++++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ 2 files changed, 45 insertions(+) create mode 100644 25.md diff --git a/25.md b/25.md new file mode 100644 index 00000000..fa818dbe --- /dev/null +++ b/25.md @@ -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 +} diff --git a/README.md b/README.md index 446003ea..acf86894 100644 --- a/README.md +++ b/README.md @@ -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-15: End of Stored Events Notice](15.md) - [NIP-16: Event Treatment](16.md) +- [NIP-25: Reactions](25.md) ## Event Kinds @@ -29,6 +30,7 @@ NIPs stand for **Nostr Implementation Possibilities**. They exist to document wh | 3 | Contacts | 2 | | 4 | Encrypted Direct Messages | 4 | | 5 | Event Deletion | 9 | +| 7 | Reaction | 25 | Please update this list when proposing NIPs introducing new event kinds. From 89bb08ba8683a13d23db9c60a3f2a16a06333f0d Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sat, 30 Jul 2022 10:09:33 -0700 Subject: [PATCH 2/3] nip25: include dislikes/downvotes Signed-off-by: William Casarin --- 25.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/25.md b/25.md index fa818dbe..ba4c695a 100644 --- a/25.md +++ b/25.md @@ -12,6 +12,12 @@ 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". +A reaction with `content` set to `-` SHOULD be interepreted as a "dislike" or +"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 +separate tallys. + 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. From 6903ff5b2c395a550a26069f6e2b5460ae1fdca6 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sun, 31 Jul 2022 12:44:40 -0700 Subject: [PATCH 3/3] nip25: make generic like an explicit + Signed-off-by: William Casarin --- 25.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/25.md b/25.md index ba4c695a..b2942558 100644 --- a/25.md +++ b/25.md @@ -9,8 +9,8 @@ Reactions 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 generic reaction, represented by the `content` set to a `+` string, SHOULD +be interpreted as a "like" or "upvote". A reaction with `content` set to `-` SHOULD be interepreted as a "dislike" or "downvote". It SHOULD NOT be counted as a "like", and MAY be displayed as a