mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-12-22 08:25:53 -05:00
NIP-29: Simple Groups (#566)
* NIP-29: Simple Group Chat. * split hostname and subgroup path into two different tag items. * add and remove permissions actions. * fix kind number for moderation event. * add missing / to "flavors" in example. * some new ideas + making this universal and not only applicable to chat. * fix delete-message => delete-event. * flesh out the entire thing. * saner approach with multiple kinds for moderation. * delete-event as kind 9005. * update meta events description. * `public` and `open` tags and join request event. * edit-group-status permission. * add kinds to README. * add kind:12 * add nip-10 note * add optional list of members * admins prefixed by "p". * remove "alt" from event templates for brevity. * add kind 10009 for public list of simple groups. * update "previous" stuff. * remove naddr stuff, use a different identifier format. * remove reference to trimmed signatures until that is more developed. * add kind:10 threaded chat replies. --------- Co-authored-by: Pablo Fernandez <p@f7z.io>
This commit is contained in:
parent
f3a2356484
commit
5b2461eb01
197
29.md
Normal file
197
29.md
Normal file
|
@ -0,0 +1,197 @@
|
||||||
|
NIP-29
|
||||||
|
======
|
||||||
|
|
||||||
|
Relay-based Groups
|
||||||
|
------------------
|
||||||
|
|
||||||
|
`draft` `optional`
|
||||||
|
|
||||||
|
This NIP defines a standard for groups that are only writable by a closed set of users. They can be public for reading by external users or not.
|
||||||
|
|
||||||
|
Groups are identified by a random string of any length that serves as an _id_.
|
||||||
|
|
||||||
|
There is no way to create a group, what happens is just that relays (most likely when asked by users) will create rules around some specific ids so these ids can serve as an actual group, henceforth messages sent to that group will be subject to these rules.
|
||||||
|
|
||||||
|
Normally a group will originally belong to one specific relay, but the community may choose to move the group to other relays or even fork the group so it exists in different forms -- still using the same _id_ -- across different relays.
|
||||||
|
|
||||||
|
## Relay-generated events
|
||||||
|
|
||||||
|
Relays are supposed to generate the events that describe group metadata and group admins. These are parameterized replaceable events signed by the relay keypair directly, with the group _id_ as the `d` tag.
|
||||||
|
|
||||||
|
## Group identifier
|
||||||
|
|
||||||
|
A group may be identified by a string in the format `<host>'<group-id>`. For example, a group with _id_ `abcdef` hosted at the relay `wss://groups.nostr.com` would be identified by the string `groups.nostr.com'abcdef`.
|
||||||
|
|
||||||
|
## The `h` tag
|
||||||
|
|
||||||
|
Events sent by users to groups (chat messages, text notes, moderation events etc) must have an `h` tag with the value set to the group _id_.
|
||||||
|
|
||||||
|
## Timeline references
|
||||||
|
|
||||||
|
In order to not be used out of context, events sent to these groups may contain references to previous events seen from the same relay in the `previous` tag. The choice of which previous events to pick belongs to the clients. The references are to be made using the first 8 characters (4 bytes) of any event in the last 50 events seen by the user in the relay, excluding events by themselves. There can be any number of references (including zero), but it's recommended that clients include at least 3 and that relays enforce this.
|
||||||
|
|
||||||
|
This is a hack to prevent messages from being broadcasted to external relays that have forks of one group out of context. Relays are expected to reject any events that contain timeline references to events not found in their own database. Clients should also check these to keep relays honest about them.
|
||||||
|
|
||||||
|
## Late publication
|
||||||
|
|
||||||
|
Relays should prevent late publication (messages published now with a timestamp from days or even hours ago) unless they are open to receive a group forked or moved from another relay.
|
||||||
|
|
||||||
|
## Event definitions
|
||||||
|
|
||||||
|
- *text root note* (`kind:11`)
|
||||||
|
|
||||||
|
This is the basic unit of a "microblog" root text note sent to a group.
|
||||||
|
|
||||||
|
```js
|
||||||
|
"kind": 11,
|
||||||
|
"content": "hello my friends lovers of pizza",
|
||||||
|
"tags": [
|
||||||
|
["h", "<group-id>"],
|
||||||
|
["previous", "<event-id-first-chars>", "<event-id-first-chars>", ...]
|
||||||
|
]
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
- *threaded text reply* (`kind:12`)
|
||||||
|
|
||||||
|
This is the basic unit of a "microblog" reply note sent to a group. It's the same as `kind:11`, except for the fact that it must be used whenever it's in reply to some other note (either in reply to a `kind:11` or a `kind:12`). `kind:12` events SHOULD use NIP-10 markers, leaving an empty relay url:
|
||||||
|
|
||||||
|
* `["e", "<kind-11-root-id>", "", "root"]`
|
||||||
|
* `["e", "<kind-12-event-id>", "", "reply"]`
|
||||||
|
|
||||||
|
- *chat message* (`kind:9`)
|
||||||
|
|
||||||
|
This is the basic unit of a _chat message_ sent to a group.
|
||||||
|
|
||||||
|
```js
|
||||||
|
"kind": 9,
|
||||||
|
"content": "hello my friends lovers of pizza",
|
||||||
|
"tags": [
|
||||||
|
["h", "<group-id>"],
|
||||||
|
["previous", "<event-id-first-chars>", "<event-id-first-chars>", ...]
|
||||||
|
]
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
- *chat message threaded reply* (`kind:10`)
|
||||||
|
|
||||||
|
Similar to `kind:12`, this is the basic unit of a chat message sent to a group. This is intended for in-chat threads that may be hidden by default. Not all in-chat replies MUST use `kind:10`, only when the intention is to create a hidden thread that isn't part of the normal flow of the chat (although clients are free to display those by default too).
|
||||||
|
|
||||||
|
`kind:10` SHOULD use NIP-10 markers, just like `kind:12`.
|
||||||
|
|
||||||
|
- *join request* (`kind:9021`)
|
||||||
|
|
||||||
|
Any user can send one of these events to the relay in order to be automatically or manually added to the group. If the group is `open` the relay will automatically issue a `kind:9000` in response adding this user. Otherwise group admins may choose to query for these requests and act upon them.
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"kind": 9021,
|
||||||
|
"content": "optional reason",
|
||||||
|
"tags": [
|
||||||
|
["h", "<group-id>"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- *moderation events* (`kinds:9000-9020`) (optional)
|
||||||
|
|
||||||
|
Clients can send these events to a relay in order to accomplish a moderation action. Relays must check if the pubkey sending the event is capable of performing the given action. The relay may discard the event after taking action or keep it as a moderation log.
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"kind": 90xx,
|
||||||
|
"content": "optional reason",
|
||||||
|
"tags": [
|
||||||
|
["h", "<group-id>"],
|
||||||
|
["previous", ...]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Each moderation action uses a different kind and requires different arguments, which are given as tags. These are defined in the following table:
|
||||||
|
|
||||||
|
| kind | name | tags |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 9000 | `add-user` | `p` (pubkey hex) |
|
||||||
|
| 9001 | `remove-user` | `p` (pubkey hex) |
|
||||||
|
| 9002 | `edit-metadata` | `name`, `about`, `picture` (string) |
|
||||||
|
| 9003 | `add-permission` | `p` (pubkey), `permission` (name) |
|
||||||
|
| 9004 | `remove-permission` | `p` (pubkey), `permission` (name) |
|
||||||
|
| 9005 | `delete-event` | `e` (id hex) |
|
||||||
|
| 9006 | `edit-group-status` | `public` or `private`, `open` or `closed` |
|
||||||
|
|
||||||
|
- *group metadata* (`kind:39000`) (optional)
|
||||||
|
|
||||||
|
This event defines the metadata for the group -- basically how clients should display it. It must be generated and signed by the relay in which is found. Relays shouldn't accept these events if they're signed by anyone else.
|
||||||
|
|
||||||
|
If the group is forked and hosted in multiple relays, there will be multiple versions of this event in each different relay and so on.
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"kind": 39000,
|
||||||
|
"content": "",
|
||||||
|
"tags": [
|
||||||
|
["d", "<group-id>"],
|
||||||
|
["name", "Pizza Lovers"],
|
||||||
|
["picture", "https://pizza.com/pizza.png"],
|
||||||
|
["about", "a group for people who love pizza"],
|
||||||
|
["public"], // or ["private"]
|
||||||
|
["open"] // or ["closed"]
|
||||||
|
]
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`name`, `picture` and `about` are basic metadata for the group for display purposes. `public` signals the group can be _read_ by anyone, while `private` signals that only AUTHed users can read. `open` signals that anyone can request to join and the request will be automatically granted, while `closed` signals that members must be pre-approved or that requests to join will be manually handled.
|
||||||
|
|
||||||
|
- *group admins* (`kind:39001`) (optional)
|
||||||
|
|
||||||
|
Similar to the group metadata, this event is supposed to be generated by relays that host the group.
|
||||||
|
|
||||||
|
Each admin gets a label that is only used for display purposes, and a list of permissions it has are listed afterwards. These permissions can inform client building UI, but ultimately are evaluated by the relay in order to become effective.
|
||||||
|
|
||||||
|
The list of capabilities, as defined by this NIP, for now, is the following:
|
||||||
|
|
||||||
|
- `add-user`
|
||||||
|
- `edit-metadata`
|
||||||
|
- `delete-event`
|
||||||
|
- `remove-user`
|
||||||
|
- `add-permission`
|
||||||
|
- `remove-permission`
|
||||||
|
- `edit-group-status`
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"kind": 39001,
|
||||||
|
"content": "list of admins for the pizza lovers group",
|
||||||
|
"tags": [
|
||||||
|
["d", "<group-id>"],
|
||||||
|
["p", "<pubkey1-as-hex>", "ceo", "add-user", "edit-metadata", "delete-event", "remove-user"],
|
||||||
|
["p", "<pubkey2-as-hex>", "secretary", "add-user", "delete-event"]
|
||||||
|
]
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- *group members* (`kind:39002`) (optional)
|
||||||
|
|
||||||
|
Similar to *group admins*, this event is supposed to be generated by relays that host the group.
|
||||||
|
|
||||||
|
It's a NIP-51-like list of pubkeys that are members of the group. Relays might choose to not to publish this information or to restrict what pubkeys can fetch it.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"kind": 39002,
|
||||||
|
"content": "list of members for the pizza lovers group",
|
||||||
|
"tags": [
|
||||||
|
["d", "<group-id>"],
|
||||||
|
["p", "<admin1>"],
|
||||||
|
["p", "<member-pubkey1>"],
|
||||||
|
["p", "<member-pubkey2>"],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Storing the list of groups a user belongs to
|
||||||
|
|
||||||
|
A definition for kind `10009` was included in [NIP-51](51.md) that allows clients to store the list of groups a user wants to remember being in.
|
1
51.md
1
51.md
|
@ -29,6 +29,7 @@ For example, _mute list_ can contain the public keys of spammers and bad actors
|
||||||
| Public chats | 10005 | [NIP-28](28.md) chat channels the user is in | `"e"` (kind:40 channel definitions) |
|
| Public chats | 10005 | [NIP-28](28.md) chat channels the user is in | `"e"` (kind:40 channel definitions) |
|
||||||
| Blocked relays | 10006 | relays clients should never connect to | `"relay"` (relay URLs) |
|
| Blocked relays | 10006 | relays clients should never connect to | `"relay"` (relay URLs) |
|
||||||
| Search relays | 10007 | relays clients should use when performing search queries | `"relay"` (relay URLs) |
|
| Search relays | 10007 | relays clients should use when performing search queries | `"relay"` (relay URLs) |
|
||||||
|
| Simple groups | 10009 | [NIP-29](29.md) groups the user is in | `"group"` ([NIP-29](29.md) group ids + mandatory relay URL) |
|
||||||
| Interests | 10015 | topics a user may be interested in and pointers | `"t"` (hashtags) and `"a"` (kind:30015 interest set) |
|
| Interests | 10015 | topics a user may be interested in and pointers | `"t"` (hashtags) and `"a"` (kind:30015 interest set) |
|
||||||
| Emojis | 10030 | user preferred emojis and pointers to emoji sets | `"emoji"` (see [NIP-30](30.md)) and `"a"` (kind:30030 emoji set) |
|
| Emojis | 10030 | user preferred emojis and pointers to emoji sets | `"emoji"` (see [NIP-30](30.md)) and `"a"` (kind:30030 emoji set) |
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
||||||
- [NIP-26: Delegated Event Signing](26.md)
|
- [NIP-26: Delegated Event Signing](26.md)
|
||||||
- [NIP-27: Text Note References](27.md)
|
- [NIP-27: Text Note References](27.md)
|
||||||
- [NIP-28: Public Chat](28.md)
|
- [NIP-28: Public Chat](28.md)
|
||||||
|
- [NIP-29: Relay-based Groups](29.md)
|
||||||
- [NIP-30: Custom Emoji](30.md)
|
- [NIP-30: Custom Emoji](30.md)
|
||||||
- [NIP-31: Dealing with Unknown Events](31.md)
|
- [NIP-31: Dealing with Unknown Events](31.md)
|
||||||
- [NIP-32: Labeling](32.md)
|
- [NIP-32: Labeling](32.md)
|
||||||
|
@ -92,6 +93,10 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
||||||
| `6` | Repost | [18](18.md) |
|
| `6` | Repost | [18](18.md) |
|
||||||
| `7` | Reaction | [25](25.md) |
|
| `7` | Reaction | [25](25.md) |
|
||||||
| `8` | Badge Award | [58](58.md) |
|
| `8` | Badge Award | [58](58.md) |
|
||||||
|
| `9` | Group Chat Message | [29](29.md) |
|
||||||
|
| `10` | Group Chat Threaded Reply | [29](29.md) |
|
||||||
|
| `11` | Group Thread | [29](29.md) |
|
||||||
|
| `12` | Group Thread Reply | [29](29.md) |
|
||||||
| `13` | Seal | [59](59.md) |
|
| `13` | Seal | [59](59.md) |
|
||||||
| `16` | Generic Repost | [18](18.md) |
|
| `16` | Generic Repost | [18](18.md) |
|
||||||
| `40` | Channel Creation | [28](28.md) |
|
| `40` | Channel Creation | [28](28.md) |
|
||||||
|
@ -112,6 +117,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
||||||
| `5000`-`5999` | Job Request | [90](90.md) |
|
| `5000`-`5999` | Job Request | [90](90.md) |
|
||||||
| `6000`-`6999` | Job Result | [90](90.md) |
|
| `6000`-`6999` | Job Result | [90](90.md) |
|
||||||
| `7000` | Job Feedback | [90](90.md) |
|
| `7000` | Job Feedback | [90](90.md) |
|
||||||
|
| `9000`-`9030` | Group Control Events | [29](29.md) |
|
||||||
| `9041` | Zap Goal | [75](75.md) |
|
| `9041` | Zap Goal | [75](75.md) |
|
||||||
| `9734` | Zap Request | [57](57.md) |
|
| `9734` | Zap Request | [57](57.md) |
|
||||||
| `9735` | Zap | [57](57.md) |
|
| `9735` | Zap | [57](57.md) |
|
||||||
|
@ -124,6 +130,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
||||||
| `10005` | Public chats list | [51](51.md) |
|
| `10005` | Public chats list | [51](51.md) |
|
||||||
| `10006` | Blocked relays list | [51](51.md) |
|
| `10006` | Blocked relays list | [51](51.md) |
|
||||||
| `10007` | Search relays list | [51](51.md) |
|
| `10007` | Search relays list | [51](51.md) |
|
||||||
|
| `10009` | User groups | [51](51.md), [29](29.md) |
|
||||||
| `10015` | Interests list | [51](51.md) |
|
| `10015` | Interests list | [51](51.md) |
|
||||||
| `10030` | User emoji list | [51](51.md) |
|
| `10030` | User emoji list | [51](51.md) |
|
||||||
| `10096` | File storage server list | [96](96.md) |
|
| `10096` | File storage server list | [96](96.md) |
|
||||||
|
@ -161,6 +168,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos
|
||||||
| `31925` | Calendar Event RSVP | [52](52.md) |
|
| `31925` | Calendar Event RSVP | [52](52.md) |
|
||||||
| `31989` | Handler recommendation | [89](89.md) |
|
| `31989` | Handler recommendation | [89](89.md) |
|
||||||
| `31990` | Handler information | [89](89.md) |
|
| `31990` | Handler information | [89](89.md) |
|
||||||
|
| `39000-9` | Group metadata events | [29](29.md) |
|
||||||
| `34550` | Community Definition | [72](72.md) |
|
| `34550` | Community Definition | [72](72.md) |
|
||||||
|
|
||||||
[nostrocket]: https://github.com/nostrocket/NIPS/blob/main/Problems.md
|
[nostrocket]: https://github.com/nostrocket/NIPS/blob/main/Problems.md
|
||||||
|
|
Loading…
Reference in New Issue
Block a user