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>2024-09-13 08:07:38 -0300
committerfiatjaf <fiatjaf@gmail.com>2024-09-13 08:39:47 -0300
commite61651ac06c662b43817f85581b50e4254efbd7b (patch)
treebcf3303515b677c55857323056199a03abc983c3
parent37a02e817b4b3e3ee7599fb1d28d97db133ef05c (diff)
nip29: make @staab happier.
-rw-r--r--29.md90
1 files changed, 75 insertions, 15 deletions
diff --git a/29.md b/29.md
index 6232f8b..f4a5436 100644
--- a/29.md
+++ b/29.md
@@ -22,6 +22,12 @@ Relays are supposed to generate the events that describe group metadata and grou
22 22
23A 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`. 23A 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`.
24 24
25Group identifiers must be strings restricted to the characters `a-z0-9-_`.
26
27When encountering just the `<host>` without the `'<group-id>`, clients can choose to connect to the group with id `_`, which is a special top-level group dedicated to relay-local discussions.
28
29Group identifiers in most cases should be random or pseudo-random, as that mitigates message replay confusiong and ensures they can be migrated or forked to other relays easily without risking conflicting with other groups using the same id in these new relays. This isn't a hard rule, as, for example, in `unmanaged` and/or ephemeral relays groups might not want to migrate ever, so they might not care about this. Notably, the `_` relay-local group isn't expected to be migrated ever.
30
25## The `h` tag 31## The `h` tag
26 32
27Events 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_. 33Events 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_.
@@ -36,8 +42,22 @@ This is a hack to prevent messages from being broadcasted to external relays tha
36 42
37Relays 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. 43Relays 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.
38 44
45## Unmanaged groups
46
47Unmanaged groups are impromptu groups that can be used in any public relay unaware of NIP-29 specifics. They piggyback on relays' natural white/blacklists (or lack of) but aside from that are not actively managed and won't have any admins, group state or metadata events.
48
49In `unmanaged` groups, everybody is considered to be a member.
50
51Unmanaged groups can transition to managed groups, in that case the relay master key just has to publish moderation events setting the state of all groups and start enforcing the rules they choose to.
52
39## Event definitions 53## Event definitions
40 54
55These are the events expected to be found in NIP-29 groups.
56
57### Normal user-created events
58
59These events generally can be sent by all members of a group and they require the `h` tag to be present so they're attached to a specific group.
60
41- *text root note* (`kind:11`) 61- *text root note* (`kind:11`)
42 62
43This is the basic unit of a "microblog" root text note sent to a group. 63This is the basic unit of a "microblog" root text note sent to a group.
@@ -79,6 +99,14 @@ Similar to `kind:12`, this is the basic unit of a chat message sent to a group.
79 99
80`kind:10` SHOULD use NIP-10 markers, just like `kind:12`. 100`kind:10` SHOULD use NIP-10 markers, just like `kind:12`.
81 101
102- other events:
103
104Groups may also accept other events, like long-form articles, calendar, livestream, market announcements and so on. These should be as defined in their respective NIPs, with the addition of the `h` tag.
105
106### User-related group management events
107
108These are events that can be sent my user to manage their situation in a group, they also require the `h` tag.
109
82- *join request* (`kind:9021`) 110- *join request* (`kind:9021`)
83 111
84Any 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. 112Any 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.
@@ -88,11 +116,14 @@ Any user can send one of these events to the relay in order to be automatically
88 "kind": 9021, 116 "kind": 9021,
89 "content": "optional reason", 117 "content": "optional reason",
90 "tags": [ 118 "tags": [
91 ["h", "<group-id>"] 119 ["h", "<group-id>"],
120 ["claim", "<optional-invite-code>"]
92 ] 121 ]
93} 122}
94``` 123```
95 124
125The optional `claim` tag may be used by the relay to preauthorize acceptances in `closed` groups, together with the `kind:9009` `create-invite` moderation event.
126
96- *leave request* (`kind:9022`) 127- *leave request* (`kind:9022`)
97 128
98Any user can send one of these events to the relay in order to be automatically removed from the group. The relay will automatically issue a `kind:9001` in response removing this user. 129Any user can send one of these events to the relay in order to be automatically removed from the group. The relay will automatically issue a `kind:9001` in response removing this user.
@@ -107,6 +138,10 @@ Any user can send one of these events to the relay in order to be automatically
107} 138}
108``` 139```
109 140
141### Group state -- or moderation
142
143These are events expected to be sent by the relay master key or by group admins -- and relays should reject them if they don't come from an authorized admin. They also require the `h` tag.
144
110- *moderation events* (`kinds:9000-9020`) (optional) 145- *moderation events* (`kinds:9000-9020`) (optional)
111 146
112Clients 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. 147Clients 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.
@@ -124,17 +159,24 @@ Clients can send these events to a relay in order to accomplish a moderation act
124 159
125Each moderation action uses a different kind and requires different arguments, which are given as tags. These are defined in the following table: 160Each moderation action uses a different kind and requires different arguments, which are given as tags. These are defined in the following table:
126 161
127| kind | name | tags | 162| kind | name | tags |
128| --- | --- | --- | 163| --- | --- | --- |
129| 9000 | `add-user` | `p` (pubkey hex) | 164| 9000 | `add-user` | `p` (pubkey hex) |
130| 9001 | `remove-user` | `p` (pubkey hex) | 165| 9001 | `remove-user` | `p` (pubkey hex) |
131| 9002 | `edit-metadata` | `name`, `about`, `picture` (string) | 166| 9002 | `edit-metadata` | `name`, `about`, `picture` (string) |
132| 9003 | `add-permission` | `p` (pubkey), `permission` (name) | 167| 9003 | `add-permission` | `p` (pubkey), `permission` (name) |
133| 9004 | `remove-permission` | `p` (pubkey), `permission` (name) | 168| 9004 | `remove-permission` | `p` (pubkey), `permission` (name) |
134| 9005 | `delete-event` | `e` (id hex) | 169| 9005 | `delete-event` | `e` (id hex) |
135| 9006 | `edit-group-status` | `public` or `private`, `open` or `closed` | 170| 9006 | `edit-group-status` | `public` or `private`, `open` or `closed` |
136| 9007 | `create-group` | | 171| 9007 | `create-group` | |
137| 9008 | `delete-group` | | 172| 9008 | `delete-group` | |
173| 9009 | `create-invite` | `code`, `uses` (how many times it can be used) |
174
175It's expected that the group state (of who is an allowed member or not, who is an admin and with which permission or not, what are the group name and picture etc) can be fully reconstructed from the canonical sequence of these events.
176
177### Group metadata events
178
179These events contain the group id in a `d` tag instead of the `h` tag. They are expected to be created by the relay master key only and a single instance of each (or none) should exist at all times for each group. They are merely informative but should reflect the latest group state (as it was changed by moderation events over time).
138 180
139- *group metadata* (`kind:39000`) (optional) 181- *group metadata* (`kind:39000`) (optional)
140 182
@@ -142,6 +184,8 @@ This event defines the metadata for the group -- basically how clients should di
142 184
143If the group is forked and hosted in multiple relays, there will be multiple versions of this event in each different relay and so on. 185If the group is forked and hosted in multiple relays, there will be multiple versions of this event in each different relay and so on.
144 186
187When this event is not found, clients may still connect to the group, but treat it as having a different status, `unmanaged`,
188
145```jsonc 189```jsonc
146{ 190{
147 "kind": 39000, 191 "kind": 39000,
@@ -194,7 +238,9 @@ The list of capabilities, as defined by this NIP, for now, is the following:
194 238
195Similar to *group admins*, this event is supposed to be generated by relays that host the group. 239Similar to *group admins*, this event is supposed to be generated by relays that host the group.
196 240
197It'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. 241It's a 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.
242
243Clients should not assume this will always be present or that it will contain a full list of members, as relays may opt to not publish it or publish a shortened version.
198 244
199```json 245```json
200{ 246{
@@ -209,6 +255,20 @@ It's a NIP-51-like list of pubkeys that are members of the group. Relays might c
209} 255}
210``` 256```
211 257
212## Storing the list of groups a user belongs to 258## Implementation quirks
259
260### Checking your own membership in a group
261
262The latest of either `kind:9000` or `kind:9001` events present in a group should tell a user that they are currently members of the group or if they were removed. In case none of these exist the user is assumed to not be a member of the group -- unless the group is `unmanaged`, in which case the user is assumed to be a member.
263
264### Adding yourself to a group
265
266When a group is `open`, anyone can send a `kind:9021` event to it in order to be added, then expect a `kind:9000` event to be emitted confirming that the user was added. The same happens with `closed` groups, except in that case a user may only send a `kind:9021` if it has an invite code.
267
268### Storing your list of groups
269
270A 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.
271
272### Using `unmanaged` relays
213 273
214A 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. 274To prevent event leakage, replay and confusion, when using `unmanaged` relays, clients should include the [NIP-70](70.md) `-` tag, as just the `previous` tag won't be checked by other `unmanaged` relays.