-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIP-22 - Generic Comment #1233
Open
arthurfranca
wants to merge
9
commits into
nostr-protocol:master
Choose a base branch
from
arthurfranca:comment
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
NIP-22 - Generic Comment #1233
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
75b02b3
Add generic comment
arthurfranca bccd745
Add convention on relay selection
arthurfranca 1c34174
Remove kind:1 mention
arthurfranca 61addbd
Add kind to i reference
arthurfranca a52b483
Update 22.md
arthurfranca a6a71cd
Add K tag
arthurfranca 6af79cb
Add prefixes to help when parsing values
arthurfranca 278601d
Add other prefixes
arthurfranca 194d1d7
Make o and r tags variadic
arthurfranca File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
NIP-22 | ||
====== | ||
|
||
Comment | ||
------- | ||
|
||
`draft` `optional` | ||
|
||
A comment is meant to be used to comment on | ||
or reply to anything except event kinds | ||
whose specifications have already defined other | ||
ways to comment on or reply to them. | ||
|
||
For example, it can be used to comment on a [NIP-23](23.md) `kind:30023` nostr blog post | ||
or on an off-nostr news article or to reply to another comment. | ||
|
||
## Structure | ||
|
||
A comment is an event of `kind:1111` with plaintext `.content` | ||
(no HTML, no Markdown nor other formatting). | ||
|
||
It must have a `k` tag pointing to the kind of the subject being commented on. | ||
For example, when commenting on a `kind:30023`, the `k` tag is set to "30023". | ||
When replying to another `kind:1111`, the `k` tag is set to "1111". | ||
If commenting on an `https://abc.com/articles/1` article the `k` tag is set to "https://abc.com" (its domain). | ||
The `k` tag is useful to fetch top-level comments about events of specific kinds (or domains), for example, | ||
by filtering with `{ "#k": ["30023"], "kinds": [1111] }`. | ||
|
||
### Threads | ||
|
||
There is always an `o` tag pointing to the original post that started the thread. | ||
It can be an event id (with an `"i:<event-kind>:<event-pubkey>:"` prefix), | ||
an event address (`"a:"` prefix) or an url (`"<protocol>"` prefix). The second value | ||
is the optional recommended relay url where the referenced event may be found. | ||
This tag is useful to load all messages of a thread at once. | ||
|
||
Note that if commenting on a replaceable event, one can choose to add both id and address references. | ||
|
||
Examples: | ||
|
||
- `["o", "i:<event-kind>:<event-pubkey>:<event-id>", "<relay-url, optional>"]` | ||
- `["o", "a:<event-kind>:<event-pubkey>:<d-tag, optional>", "<relay-url, optional>"]` | ||
- `["o", "https://abc.com/articles/1/"]` | ||
|
||
Also, there is always an `r` tag pointing to the subject being directly commented on or replied to, using the | ||
same structure of the `o` tag. | ||
This tag is useful to lazily load a thread. | ||
|
||
#### Thread Relays | ||
|
||
If the original post being commented on is a nostr event and | ||
the client supports the [NIP-65](65.md) relay usage spec, | ||
`kind:1111` events should be sent atleast to the original post author's `read` relays. | ||
|
||
### Event Examples | ||
|
||
```js | ||
{ | ||
w: 1111, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My wwwwwww key is getting stuck |
||
content: 'Agree with your comment.', | ||
tags: [ | ||
// referencing the OP | ||
["o", "https://abc.com/articles/1/"], | ||
// replying to a parent kind:1111 comment | ||
["r", "i:1111:f7234bd4c1394dda46d09f35bd384dd30cc552ad5541990f98844fb06676e9ca:5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"], | ||
// the parent kind | ||
["k", "1111"] | ||
] | ||
// other fields | ||
} | ||
``` | ||
|
||
```js | ||
{ | ||
kind: 1111, | ||
content: 'Great blog post! Check this out nostr:npub1sn0wdenkukak0d9dfczzeacvhkrgz92ak56egt7vdgzn8pv2wfqqhrjdv9.', | ||
tags: [ | ||
// top-level comments have the same o and r tags | ||
["o", "a:30023:3c9849383bdea883b0bd16fece1ed36d37e37cdde3ce43b17ea4e9192ec11289:f9347ca7"], | ||
["r", "a:30023:3c9849383bdea883b0bd16fece1ed36d37e37cdde3ce43b17ea4e9192ec11289:f9347ca7"], | ||
// the parent kind | ||
["k", "30023"], | ||
// the nostr:npub1... mentioned on .content | ||
["p", "84dee6e676e5bb67b4ad4e042cf70cbd8681155db535942fcc6a0533858a7240"] | ||
] | ||
// other fields | ||
} | ||
``` | ||
|
||
Note that ideally there are no `p` tags unless the pubkey is being mentioned on the `.content`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if you want to fetch top level comments for some kinds, including replies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like coracle that shows not only root/OP posts and top-level replies but also any-level replies in the feed?
A
K
tag with the OP kind would do it instead of using the lowercase one. I will add it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like top level replies have no real use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider them high signal and great to include to the feed as they carry the start of the conversation as context. Very similar to quotes.
In contrast, reply of reply of reply tend to get off-topic and carry an incomplete context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of any use cases for filtering by
K
andk
tags. Maybe it's a similar discussion to #815?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, like generic reposts too. When we pick one event kind to be a generic thing, clients need a way to ask relays for just things related to a specific kind. Ex: reposts of 30023 to show on a blog's first page as "recommended articles".
Without
k
, client would have to download all generic stuff, check individually what are they referencing and discard those that reference events the client doesn't support/want.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I quote @fiatjaf comment in #815.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K
is useful if you have a reply feed, like Damus and Amethyst do. Frankly, I don't think the reply feed is that useful but so many people use it that it's kind of a requirement for kind1 feeds these days.And the reply feed only exists because kind1 clients couldn't download just the root threads from follows. So it was a way to justify not wasting bandwidth of the replies without showing to users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see! I hadn't thought of a reply feed. Thanks Vitor.