From 3ed14fe70ab413ef32a748af065298e7226e9558 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 4 Nov 2023 17:08:37 -0300 Subject: [PATCH] some new ideas + making this universal and not only applicable to chat. --- 29.md | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/29.md b/29.md index 1871b650..d283f6a1 100644 --- a/29.md +++ b/29.md @@ -1,34 +1,49 @@ 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 +- *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", ""], + ["previous", "", "", ...] + ] + ... +``` + - *chat message* (`kind:9`) -This is the basic unit of a 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...`). +Similar to kind 11, this is the basic unit of a chat message sent to a group. ```js "kind": 9, "content": "hello my friends lovers of pizza", "tags": [ - ["g", "/flavors", "pizza.com"] + ["h", ""], + ["previous", "", "", ...] ] ... ``` @@ -42,7 +57,7 @@ If this event does not exist, the group should be identified in the client UI by "kind": 39000, "content": "a nip-29 chat group for debating pizza flavors and other topics", "tags": [ - ["d", "/flavors"], + ["d", ""], ["name", "Pizza Lovers"], ["picture", "https://pizza.com/pizza.png"], ["private"], @@ -60,7 +75,7 @@ The list of capabilities, as defined by this NIP, for now, is the following: - `add-user` - `edit-metadata` -- `delete-message` +- `delete-event` - `ban-user` - `add-permission` - `remove-permission` @@ -70,7 +85,7 @@ The list of capabilities, as defined by this NIP, for now, is the following: "kind": 39001, "content": "list of admins for the pizza lovers group", "tags": [ - ["d", "/flavors"], + ["d", ""], ["", "admin", "add-user", "edit-metadata", "delete-message", "ban-user"], ["", "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, "content": "action description and/or reason", "tags": [ - ["g", "/flavors", "pizza.com"], + ["g", ""], ["action", "add-user", ""], ["action", "ban-user", ""], ["action", "delete-message", ""],