mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-11-09 22:09:06 -05:00
some new ideas + making this universal and not only applicable to chat.
This commit is contained in:
parent
c2cecdd668
commit
3ed14fe70a
51
29.md
51
29.md
|
@ -1,34 +1,49 @@
|
||||||
NIP-29
|
NIP-29
|
||||||
======
|
======
|
||||||
|
|
||||||
Simple Group Chat
|
Relay-based Groups
|
||||||
-----------------
|
------------------
|
||||||
|
|
||||||
`draft` `optional` `author:fiatjaf` `author:ismyhc` `depends:33` `depends:27` `depends:11` `depends:42`
|
`draft` `optional` `author:fiatjaf`
|
||||||
|
|
||||||
This NIP defines a model for group chat that relies on relays as ultimate sources of authority. Clients can connect to multiple relays and interact with different groups in each of these relays. A group can live in more than one relay or migrate between relays, but for practical purposes it is expected to rely on a single relay for as long as that is working well. This approach minimizes bandwidth consumption and computation costs and ensures the group can have fine-grained permissions and other niceties commonly expected from any group chat platforms without putting a huge amount of overhead on clients. The fundamental assumption here is that censorship is not a big concern for this kind of application.
|
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.
|
||||||
|
|
||||||
Each group has an identifier, which is used as the `d` tag (see [NIP-33](33.md)) in events that hold group metadata. The default top-level group in a relay is identified by `"/"`, with subgroups added after the slash and even deeper subgroups separated by other slashes. The imagined user flow for opening a group is to type a hostname with an optional path suffix. For example, if the user types `pizza.com/` that goes to the top-level group at the `wss://pizza.com` relay. If the user types `pizza.com/flavors` that goes to the group `"/flavors"` on the `wss://pizza.com` relay.
|
## Timeline references
|
||||||
|
|
||||||
The entire metadata of the group (kinds `39000-3900x`) must only be signed by the relay main pubkey given by the `"pubkey"` field in the relay's [NIP-11](11.md) response. Other metadata events not signed by that public key must be ignored by clients. Upon opening a group, the chat client is supposed to fetch (or use locally cached values) these metadata events in order to render the group details, and then fetch the messages (`kind:9`).
|
In order to not be used out of context, events sent to these groups may contain a reference to previous events seen from the same relay.
|
||||||
|
|
||||||
|
## Trimmed signatures
|
||||||
|
|
||||||
|
For private groups that are not intended to be read by external users, relays must strip the signatures before sending the events to clients.
|
||||||
|
|
||||||
### Event definitions
|
### Event definitions
|
||||||
|
|
||||||
|
- *text note* (`kind:11`)
|
||||||
|
|
||||||
|
This is the basic unit of a text note sent to a group.
|
||||||
|
|
||||||
|
It must commit in the `h` tag to the subgroup path and may also commit to up to the last 3 events of the same kind seen in the group.
|
||||||
|
|
||||||
|
```js
|
||||||
|
"kind": 11,
|
||||||
|
"content": "hello my friends lovers of pizza",
|
||||||
|
"tags": [
|
||||||
|
["h", "<group-id>"],
|
||||||
|
["previous", "<event-id>", "<event-id>", ...]
|
||||||
|
]
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
- *chat message* (`kind:9`)
|
- *chat message* (`kind:9`)
|
||||||
|
|
||||||
This is the basic unit of a message sent to a group.
|
Similar to kind 11, this is the basic unit of a chat message sent to a group.
|
||||||
|
|
||||||
It must commit in the `g` tag to the subgroup path and also to the relay hostname (in order to prevent these events from being sent to other relays and groups out of context and cause confusion).
|
|
||||||
|
|
||||||
`e` and `p` tags can also be used to signal an immediate reply to another message on the group or to call for the attention of some other group user.
|
|
||||||
|
|
||||||
When inserting references -- in the body of the text -- to users, other messages (quotes) and to other Nostr events that outside of the group must be made following the [NIP-27](27.md) pattern (`nostr:nevent1...`).
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"kind": 9,
|
"kind": 9,
|
||||||
"content": "hello my friends lovers of pizza",
|
"content": "hello my friends lovers of pizza",
|
||||||
"tags": [
|
"tags": [
|
||||||
["g", "/flavors", "pizza.com"]
|
["h", "<group-id>"],
|
||||||
|
["previous", "<event-id>", "<event-id>", ...]
|
||||||
]
|
]
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
@ -42,7 +57,7 @@ If this event does not exist, the group should be identified in the client UI by
|
||||||
"kind": 39000,
|
"kind": 39000,
|
||||||
"content": "a nip-29 chat group for debating pizza flavors and other topics",
|
"content": "a nip-29 chat group for debating pizza flavors and other topics",
|
||||||
"tags": [
|
"tags": [
|
||||||
["d", "/flavors"],
|
["d", "<group-id>"],
|
||||||
["name", "Pizza Lovers"],
|
["name", "Pizza Lovers"],
|
||||||
["picture", "https://pizza.com/pizza.png"],
|
["picture", "https://pizza.com/pizza.png"],
|
||||||
["private"],
|
["private"],
|
||||||
|
@ -60,7 +75,7 @@ The list of capabilities, as defined by this NIP, for now, is the following:
|
||||||
|
|
||||||
- `add-user`
|
- `add-user`
|
||||||
- `edit-metadata`
|
- `edit-metadata`
|
||||||
- `delete-message`
|
- `delete-event`
|
||||||
- `ban-user`
|
- `ban-user`
|
||||||
- `add-permission`
|
- `add-permission`
|
||||||
- `remove-permission`
|
- `remove-permission`
|
||||||
|
@ -70,7 +85,7 @@ The list of capabilities, as defined by this NIP, for now, is the following:
|
||||||
"kind": 39001,
|
"kind": 39001,
|
||||||
"content": "list of admins for the pizza lovers group",
|
"content": "list of admins for the pizza lovers group",
|
||||||
"tags": [
|
"tags": [
|
||||||
["d", "/flavors"],
|
["d", "<group-id>"],
|
||||||
["<pubkey1-as-hex>", "admin", "add-user", "edit-metadata", "delete-message", "ban-user"],
|
["<pubkey1-as-hex>", "admin", "add-user", "edit-metadata", "delete-message", "ban-user"],
|
||||||
["<pubkey2-as-hex>", "mod", "add-user", "delete-message"]
|
["<pubkey2-as-hex>", "mod", "add-user", "delete-message"]
|
||||||
]
|
]
|
||||||
|
@ -87,7 +102,7 @@ An event sent from a client to the relay in order to accomplish a moderation act
|
||||||
"kind": 9000,
|
"kind": 9000,
|
||||||
"content": "action description and/or reason",
|
"content": "action description and/or reason",
|
||||||
"tags": [
|
"tags": [
|
||||||
["g", "/flavors", "pizza.com"],
|
["g", "<group-id>"],
|
||||||
["action", "add-user", "<pubkey-to-add>"],
|
["action", "add-user", "<pubkey-to-add>"],
|
||||||
["action", "ban-user", "<pubkey-to-ban>"],
|
["action", "ban-user", "<pubkey-to-ban>"],
|
||||||
["action", "delete-message", "<event-id-to-delete>"],
|
["action", "delete-message", "<event-id-to-delete>"],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user