upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiatjaf <fiatjaf@gmail.com>2023-11-04 17:08:37 -0300
committerfiatjaf <fiatjaf@gmail.com>2024-02-23 20:51:46 -0300
commit3ed14fe70ab413ef32a748af065298e7226e9558 (patch)
tree3c73c8242d5d8a560713a5aa511bf02e092b5d69
parentc2cecdd66818690125c6d3ad0f4e330c306f7d1a (diff)
some new ideas + making this universal and not only applicable to chat.
-rw-r--r--29.md47
1 files changed, 31 insertions, 16 deletions
diff --git a/29.md b/29.md
index 1871b65..d283f6a 100644
--- a/29.md
+++ b/29.md
@@ -1,34 +1,49 @@
1NIP-29 1NIP-29
2====== 2======
3 3
4Simple Group Chat 4Relay-based Groups
5----------------- 5------------------
6 6
7`draft` `optional` `author:fiatjaf` `author:ismyhc` `depends:33` `depends:27` `depends:11` `depends:42` 7`draft` `optional` `author:fiatjaf`
8 8
9This 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. 9This 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.
10 10
11Each 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. 11## Timeline references
12 12
13The 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`). 13In 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.
14
15## Trimmed signatures
16
17For private groups that are not intended to be read by external users, relays must strip the signatures before sending the events to clients.
14 18
15### Event definitions 19### Event definitions
16 20
17- *chat message* (`kind:9`) 21- *text note* (`kind:11`)
18 22
19This is the basic unit of a message sent to a group. 23This is the basic unit of a text note sent to a group.
20 24
21It 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). 25It 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.
22 26
23`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. 27```js
28 "kind": 11,
29 "content": "hello my friends lovers of pizza",
30 "tags": [
31 ["h", "<group-id>"],
32 ["previous", "<event-id>", "<event-id>", ...]
33 ]
34 ...
35```
36
37- *chat message* (`kind:9`)
24 38
25When 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...`). 39Similar to kind 11, this is the basic unit of a chat message sent to a group.
26 40
27```js 41```js
28 "kind": 9, 42 "kind": 9,
29 "content": "hello my friends lovers of pizza", 43 "content": "hello my friends lovers of pizza",
30 "tags": [ 44 "tags": [
31 ["g", "/flavors", "pizza.com"] 45 ["h", "<group-id>"],
46 ["previous", "<event-id>", "<event-id>", ...]
32 ] 47 ]
33 ... 48 ...
34``` 49```
@@ -42,7 +57,7 @@ If this event does not exist, the group should be identified in the client UI by
42 "kind": 39000, 57 "kind": 39000,
43 "content": "a nip-29 chat group for debating pizza flavors and other topics", 58 "content": "a nip-29 chat group for debating pizza flavors and other topics",
44 "tags": [ 59 "tags": [
45 ["d", "/flavors"], 60 ["d", "<group-id>"],
46 ["name", "Pizza Lovers"], 61 ["name", "Pizza Lovers"],
47 ["picture", "https://pizza.com/pizza.png"], 62 ["picture", "https://pizza.com/pizza.png"],
48 ["private"], 63 ["private"],
@@ -60,7 +75,7 @@ The list of capabilities, as defined by this NIP, for now, is the following:
60 75
61- `add-user` 76- `add-user`
62- `edit-metadata` 77- `edit-metadata`
63- `delete-message` 78- `delete-event`
64- `ban-user` 79- `ban-user`
65- `add-permission` 80- `add-permission`
66- `remove-permission` 81- `remove-permission`
@@ -70,7 +85,7 @@ The list of capabilities, as defined by this NIP, for now, is the following:
70 "kind": 39001, 85 "kind": 39001,
71 "content": "list of admins for the pizza lovers group", 86 "content": "list of admins for the pizza lovers group",
72 "tags": [ 87 "tags": [
73 ["d", "/flavors"], 88 ["d", "<group-id>"],
74 ["<pubkey1-as-hex>", "admin", "add-user", "edit-metadata", "delete-message", "ban-user"], 89 ["<pubkey1-as-hex>", "admin", "add-user", "edit-metadata", "delete-message", "ban-user"],
75 ["<pubkey2-as-hex>", "mod", "add-user", "delete-message"] 90 ["<pubkey2-as-hex>", "mod", "add-user", "delete-message"]
76 ] 91 ]
@@ -87,7 +102,7 @@ An event sent from a client to the relay in order to accomplish a moderation act
87 "kind": 9000, 102 "kind": 9000,
88 "content": "action description and/or reason", 103 "content": "action description and/or reason",
89 "tags": [ 104 "tags": [
90 ["g", "/flavors", "pizza.com"], 105 ["g", "<group-id>"],
91 ["action", "add-user", "<pubkey-to-add>"], 106 ["action", "add-user", "<pubkey-to-add>"],
92 ["action", "ban-user", "<pubkey-to-ban>"], 107 ["action", "ban-user", "<pubkey-to-ban>"],
93 ["action", "delete-message", "<event-id-to-delete>"], 108 ["action", "delete-message", "<event-id-to-delete>"],