From 3e9ebfe59ebd9971fd5c1385cf66381ea16fddd3 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 23 Sep 2024 10:47:34 -0700 Subject: [PATCH 1/9] First pass at relay chat NIP --- xx.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 xx.md diff --git a/xx.md b/xx.md new file mode 100644 index 0000000000..7b1f70ae59 --- /dev/null +++ b/xx.md @@ -0,0 +1,56 @@ +NIP-XX +====== + +Relay Chat +---------- + +`draft` `optional` + +This NIP defines a standard for relay-local chat messages. + +# Chat Message + +A relay chat message is a kind `209` event. A `~` tag MUST be included, indicating the name of the chat room and the relay url. Chat room IDs SHOULD be human-readable, and no longer than 30 characters. + +```json +{ + "content": "GM", + "tags": [ + ["~", "Good Morning", "wss://relay.example.com/"], + ] +} +``` + +Replies to kind `209` MUST use [NIP-73](https://github.com/nostr-protocol/nips/pull/1233) `kind 1111` comments. Clients MAY support arbitrarily nested replies, but SHOULD encourage flat reply hierarchies. + +# Membership + +Users MAY track and optionally advertise their own group memberships using a [NIP 51](51.md) kind `10209` event. Tags MAY be either public or encrypted with [NIP 44](44.md), depending on user/client preference. + +Room membership SHOULD be indicated using both an `r` tag for each relay the user is a member of, and a `~` tag for each room the user is a member of. `~` tags MUST include a relay url as the second argument. + +```json +{ + "kind": "10209", + "tags": [ + ["r", "wss://relay.other.com/"], + ["~", "Good Morning", "wss://relay.other.com/"] + ], +} +``` + +# Migrations + +If a conversation needs to be moved from one relay to another, the new host relay may explicitly map this relation using a `kind 30209` event indicating valid relay urls for a given room. Multiple previous urls may be supported for a single room. + +```json +{ + "kind": "30209", + "tags": [ + ["~", "Good Morning", "wss://relay.other1.com/"], + ["~", "Good Morning", "wss://relay.other2.com/"] + ], +} +``` + +Chat messages MUST NOT be considered valid unless they have an `~` tag matching the current relay, or a relay specified in a `kind 30209` migration event. From 27da12d3a74c2d862a51457a3658334f8b4db913 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 24 Sep 2024 16:03:25 -0700 Subject: [PATCH 2/9] Explain that other note kinds can be posted to rooms --- xx.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xx.md b/xx.md index 7b1f70ae59..c26a99dfa0 100644 --- a/xx.md +++ b/xx.md @@ -8,12 +8,19 @@ Relay Chat This NIP defines a standard for relay-local chat messages. +# Rooms + +A `room` is identified by an arbitrary, human-readable string no longer than 30 characters and referred to using a `~` tag indicating the room id and a relay url. + +Rooms on different relays with the same name SHOULD NOT be considered the same room. + # Chat Message -A relay chat message is a kind `209` event. A `~` tag MUST be included, indicating the name of the chat room and the relay url. Chat room IDs SHOULD be human-readable, and no longer than 30 characters. +A relay chat message is a kind `209` event. A `~` tag MUST be included, indicating the name of the chat room and the relay url. ```json { + "kind": 209, "content": "GM", "tags": [ ["~", "Good Morning", "wss://relay.example.com/"], @@ -23,6 +30,8 @@ A relay chat message is a kind `209` event. A `~` tag MUST be included, indicati Replies to kind `209` MUST use [NIP-73](https://github.com/nostr-protocol/nips/pull/1233) `kind 1111` comments. Clients MAY support arbitrarily nested replies, but SHOULD encourage flat reply hierarchies. +Other note kinds MAY be posted to rooms, but care should be taken that any non-`kind 209` events will make sense out of context either of the room or the host relay. + # Membership Users MAY track and optionally advertise their own group memberships using a [NIP 51](51.md) kind `10209` event. Tags MAY be either public or encrypted with [NIP 44](44.md), depending on user/client preference. @@ -41,7 +50,7 @@ Room membership SHOULD be indicated using both an `r` tag for each relay the use # Migrations -If a conversation needs to be moved from one relay to another, the new host relay may explicitly map this relation using a `kind 30209` event indicating valid relay urls for a given room. Multiple previous urls may be supported for a single room. +If a conversation needs to be moved from one relay to another, the new host relay may explicitly map this relation using a `kind 30209` event indicating valid relay urls for a given room. Multiple previous urls may be supported for a single room. This event MUST be signed by the `pubkey` indicated by the relay's NIP 11 document. ```json { @@ -53,4 +62,4 @@ If a conversation needs to be moved from one relay to another, the new host rela } ``` -Chat messages MUST NOT be considered valid unless they have an `~` tag matching the current relay, or a relay specified in a `kind 30209` migration event. +Chat messages MUST NOT be considered valid unless they have a `~` tag matching the current relay, or a relay specified in a `kind 30209` migration event. From 40d904a54bbe0a1461d74fc7fd3e427082310dfe Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 2 Oct 2024 13:17:26 -0700 Subject: [PATCH 3/9] Clarify that other notes can be posted with ~ --- xx.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xx.md b/xx.md index c26a99dfa0..5c4fb9e097 100644 --- a/xx.md +++ b/xx.md @@ -28,9 +28,11 @@ A relay chat message is a kind `209` event. A `~` tag MUST be included, indicati } ``` -Replies to kind `209` MUST use [NIP-73](https://github.com/nostr-protocol/nips/pull/1233) `kind 1111` comments. Clients MAY support arbitrarily nested replies, but SHOULD encourage flat reply hierarchies. +Replies to kind `209` MUST use [NIP-73](https://github.com/nostr-protocol/nips/pull/1233) `kind 1111` comments. Clients MAY support arbitrarily nested replies, but SHOULD encourage flat reply hierarchies. These replies MUST also include a `~` tag. -Other note kinds MAY be posted to rooms, but care should be taken that any non-`kind 209` events will make sense out of context either of the room or the host relay. +Kind `209` events MUST NOT be considered valid unless they have a `~` tag matching the current relay, or a relay specified in a `kind 30209` migration event. + +Other note kinds MAY also be posted to rooms using the `~` tag. # Membership @@ -61,5 +63,3 @@ If a conversation needs to be moved from one relay to another, the new host rela ], } ``` - -Chat messages MUST NOT be considered valid unless they have a `~` tag matching the current relay, or a relay specified in a `kind 30209` migration event. From c396c1944fb9bef0bbb13212183c3722b371eb69 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 22 Oct 2024 10:54:07 -0700 Subject: [PATCH 4/9] Add recommendation on where to publish 10209s --- xx.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xx.md b/xx.md index 5c4fb9e097..a826643f15 100644 --- a/xx.md +++ b/xx.md @@ -50,6 +50,9 @@ Room membership SHOULD be indicated using both an `r` tag for each relay the use } ``` +Room membership events SHOULD be sent both to the user's [NIP-65](./65.md) WRITE relays, and to +each relay listed in the membership event (in order to allow clients to build room lists). + # Migrations If a conversation needs to be moved from one relay to another, the new host relay may explicitly map this relation using a `kind 30209` event indicating valid relay urls for a given room. Multiple previous urls may be supported for a single room. This event MUST be signed by the `pubkey` indicated by the relay's NIP 11 document. From eb60e8791564ae3fc1e5ebc1416a9fc6e5981767 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 28 Oct 2024 14:20:37 -0700 Subject: [PATCH 5/9] Add threads, rename migrations to federation --- xx.md | 61 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/xx.md b/xx.md index a826643f15..6ede590f94 100644 --- a/xx.md +++ b/xx.md @@ -1,22 +1,25 @@ NIP-XX ====== -Relay Chat ----------- +Rooms +----- `draft` `optional` -This NIP defines a standard for relay-local chat messages. - # Rooms -A `room` is identified by an arbitrary, human-readable string no longer than 30 characters and referred to using a `~` tag indicating the room id and a relay url. +A `room` is identified by an arbitrary, human-readable string no longer than +30 characters and referred to using a `~` tag indicating the room id and a +relay url. Rooms on different relays with the same name ARE NOT the same room. -Rooms on different relays with the same name SHOULD NOT be considered the same room. +Any event MAY be posted to a `room` using a `~` tag. Events posted to a room +MUST NOT be considered valid unless their `~` tag matches the current relay, or +a relay specified in a `kind 30209` federation event. -# Chat Message +# Chat -A relay chat message is a kind `209` event. A `~` tag MUST be included, indicating the name of the chat room and the relay url. +A chat message is a kind `209` event with a `~` tag. Chat messages are intended +to be used as a high-frequency, informal, context-aware communication medium. ```json { @@ -28,11 +31,30 @@ A relay chat message is a kind `209` event. A `~` tag MUST be included, indicati } ``` -Replies to kind `209` MUST use [NIP-73](https://github.com/nostr-protocol/nips/pull/1233) `kind 1111` comments. Clients MAY support arbitrarily nested replies, but SHOULD encourage flat reply hierarchies. These replies MUST also include a `~` tag. +Replies to kind `209` MUST use [NIP-73](https://github.com/nostr-protocol/nips/pull/1233) +kind `1111` comments with a matching `~` tag. Clients SHOULD encourage flat reply +hierarchies. -Kind `209` events MUST NOT be considered valid unless they have a `~` tag matching the current relay, or a relay specified in a `kind 30209` migration event. +# Threads -Other note kinds MAY also be posted to rooms using the `~` tag. +A thread is a kind `309` event with a `~` tag. Threads and their replies are +intended to be used as a low-frequency, more formal, context-aware communication +medium. Threads MUST include a `title` with a summary of the `content`. + +```json +{ + "kind": 309, + "content": "GM", + "tags": [ + ["~", "Good Morning", "wss://relay.example.com/"], + ["title", "GM"] + ] +} +``` + +Replies to kind `309` MUST use [NIP-73](https://github.com/nostr-protocol/nips/pull/1233) +kind `1111` comments with a matching `~` tag. Clients SHOULD encourage flat reply +hierarchies. # Membership @@ -53,16 +75,25 @@ Room membership SHOULD be indicated using both an `r` tag for each relay the use Room membership events SHOULD be sent both to the user's [NIP-65](./65.md) WRITE relays, and to each relay listed in the membership event (in order to allow clients to build room lists). -# Migrations +# Federation + +Relays hosting rooms MAY indicate federation with other relays for rooms +by publishing a `kind 30209` event using the key indicated by the relay's +NIP 11 document. -If a conversation needs to be moved from one relay to another, the new host relay may explicitly map this relation using a `kind 30209` event indicating valid relay urls for a given room. Multiple previous urls may be supported for a single room. This event MUST be signed by the `pubkey` indicated by the relay's NIP 11 document. +A relay may indicate partial federation using one or more `~` tags, or complete +federation using a `r` tag. ```json { "kind": "30209", "tags": [ - ["~", "Good Morning", "wss://relay.other1.com/"], - ["~", "Good Morning", "wss://relay.other2.com/"] + ["r", "wss://other1.com"], + ["~", "Good Morning", "wss://other2.com/"], + ["~", "Good Morning", "wss://other3.com/"] ], } ``` + +This can be useful if a conversation needs to be moved from one relay to another, +or if multiple people want to host a conversation simultaneously. From 5e99b6fb35e9824939f850173146bc4e9dec9e99 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 18 Nov 2024 06:40:17 -0800 Subject: [PATCH 6/9] Clarify where to send room membership events --- xx.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xx.md b/xx.md index 6ede590f94..437abd6075 100644 --- a/xx.md +++ b/xx.md @@ -72,8 +72,11 @@ Room membership SHOULD be indicated using both an `r` tag for each relay the use } ``` -Room membership events SHOULD be sent both to the user's [NIP-65](./65.md) WRITE relays, and to -each relay listed in the membership event (in order to allow clients to build room lists). +Room membership events SHOULD be sent to: + +- The user's [NIP-65](./65.md) WRITE relays +- Each relay listed in the membership event +- Each relay being removed from the member list # Federation From 7e47fbdb2b632e0143dc42f7cdf3b17396c7e48d Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 19 Nov 2024 21:17:29 -0800 Subject: [PATCH 7/9] Attempt to reconcile kind 9/209 and 11/309 --- 29.md | 34 +----------------- chat.md | 29 +++++++++++++++ threads.md | 34 ++++++++++++++++++ xx.md | 102 ----------------------------------------------------- 4 files changed, 64 insertions(+), 135 deletions(-) create mode 100644 chat.md create mode 100644 threads.md delete mode 100644 xx.md diff --git a/29.md b/29.md index a116433278..a2c8ef26b5 100644 --- a/29.md +++ b/29.md @@ -64,39 +64,7 @@ These are the events expected to be found in NIP-29 groups. ### Normal user-created events -These 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. - -- _chat message_ (`kind:9`) - -This is the basic unit of a _chat message_ sent to a group. - -```jsonc - "kind": 9, - "content": "hello my friends lovers of pizza", - "tags": [ - ["h", ""], - ["previous", "", "", /*...*/] - ] - // other fields... -``` - -- _thread root post_ (`kind:11`) - -This is the basic unit of a forum-like root thread post sent to a group. - -```jsonc - "kind": 11, - "content": "hello my friends lovers of pizza", - "tags": [ - ["h", ""], - ["previous", "", "", /*...*/] - ] - // other fields... -``` - -- _other events_: - -Groups may also accept other events, like [NIP-22](22.md) comments as threaded replies to both chats messages and threads, long-form articles, calendar, livestreams, market announcements and so on. These should be as defined in their respective NIPs, with the addition of the `h` tag. +Groups may accept any event kind, including chats, threads, long-form articles, calendar, livestreams, market announcements and so on. These should be as defined in their respective NIPs, with the addition of the `h` tag. ### User-related group management events diff --git a/chat.md b/chat.md new file mode 100644 index 0000000000..64a0ae0f4b --- /dev/null +++ b/chat.md @@ -0,0 +1,29 @@ +NIP-XX +====== + +Chats +----- + +`draft` `optional` + +A chat message is a `kind 9` event. + +```json +{ + "kind": 9, + "content": "GM", + "tags": [] +} +``` + +A reply to a `kind 9` is an additional `kind 9` which quotes the parent using a `q` tag. + +```json +{ + "kind": 9, + "content": "nostr:nevent1...\nyes", + "tags": [ + ["q", , , ] + ] +} +``` diff --git a/threads.md b/threads.md new file mode 100644 index 0000000000..802365253d --- /dev/null +++ b/threads.md @@ -0,0 +1,34 @@ +NIP-XX +====== + +Threads +------- + +`draft` `optional` + +A thread is a `kind 11` event. Threads SHOULD include a `title` with a summary +of the thread's topic. + +```json +{ + "kind": 11, + "content": "Good morning", + "tags": [ + ["title", "GM"] + ] +} +``` + +Replies to `kind 11` MUST use [NIP-22](./22.md) `kind 1111` comments. Replies should +always be to the root `kind 11` to avoid arbitrarily nested reply hierarchies. + +```json +{ + "kind": 1111, + "content": "Cool beans", + "tags": [ + ["K", "11"], + ["E", , , ] + ] +} +``` diff --git a/xx.md b/xx.md deleted file mode 100644 index 437abd6075..0000000000 --- a/xx.md +++ /dev/null @@ -1,102 +0,0 @@ -NIP-XX -====== - -Rooms ------ - -`draft` `optional` - -# Rooms - -A `room` is identified by an arbitrary, human-readable string no longer than -30 characters and referred to using a `~` tag indicating the room id and a -relay url. Rooms on different relays with the same name ARE NOT the same room. - -Any event MAY be posted to a `room` using a `~` tag. Events posted to a room -MUST NOT be considered valid unless their `~` tag matches the current relay, or -a relay specified in a `kind 30209` federation event. - -# Chat - -A chat message is a kind `209` event with a `~` tag. Chat messages are intended -to be used as a high-frequency, informal, context-aware communication medium. - -```json -{ - "kind": 209, - "content": "GM", - "tags": [ - ["~", "Good Morning", "wss://relay.example.com/"], - ] -} -``` - -Replies to kind `209` MUST use [NIP-73](https://github.com/nostr-protocol/nips/pull/1233) -kind `1111` comments with a matching `~` tag. Clients SHOULD encourage flat reply -hierarchies. - -# Threads - -A thread is a kind `309` event with a `~` tag. Threads and their replies are -intended to be used as a low-frequency, more formal, context-aware communication -medium. Threads MUST include a `title` with a summary of the `content`. - -```json -{ - "kind": 309, - "content": "GM", - "tags": [ - ["~", "Good Morning", "wss://relay.example.com/"], - ["title", "GM"] - ] -} -``` - -Replies to kind `309` MUST use [NIP-73](https://github.com/nostr-protocol/nips/pull/1233) -kind `1111` comments with a matching `~` tag. Clients SHOULD encourage flat reply -hierarchies. - -# Membership - -Users MAY track and optionally advertise their own group memberships using a [NIP 51](51.md) kind `10209` event. Tags MAY be either public or encrypted with [NIP 44](44.md), depending on user/client preference. - -Room membership SHOULD be indicated using both an `r` tag for each relay the user is a member of, and a `~` tag for each room the user is a member of. `~` tags MUST include a relay url as the second argument. - -```json -{ - "kind": "10209", - "tags": [ - ["r", "wss://relay.other.com/"], - ["~", "Good Morning", "wss://relay.other.com/"] - ], -} -``` - -Room membership events SHOULD be sent to: - -- The user's [NIP-65](./65.md) WRITE relays -- Each relay listed in the membership event -- Each relay being removed from the member list - -# Federation - -Relays hosting rooms MAY indicate federation with other relays for rooms -by publishing a `kind 30209` event using the key indicated by the relay's -NIP 11 document. - -A relay may indicate partial federation using one or more `~` tags, or complete -federation using a `r` tag. - -```json -{ - "kind": "30209", - "tags": [ - ["r", "wss://other1.com"], - ["~", "Good Morning", "wss://other2.com/"], - ["~", "Good Morning", "wss://other3.com/"] - ], -} -``` - -This can be useful if a conversation needs to be moved from one relay to another, -or if multiple people want to host a conversation simultaneously. From 80599f618f3a6d66ec311d9676a89f20c1714018 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 20 Nov 2024 10:01:32 -0800 Subject: [PATCH 8/9] Rename chat and threads --- threads.md => 7D.md | 2 +- chat.md => C7.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename threads.md => 7D.md (98%) rename chat.md => C7.md (98%) diff --git a/threads.md b/7D.md similarity index 98% rename from threads.md rename to 7D.md index 802365253d..5f0e5edff5 100644 --- a/threads.md +++ b/7D.md @@ -1,4 +1,4 @@ -NIP-XX +NIP-&D ====== Threads diff --git a/chat.md b/C7.md similarity index 98% rename from chat.md rename to C7.md index 64a0ae0f4b..0d94f18b6a 100644 --- a/chat.md +++ b/C7.md @@ -1,4 +1,4 @@ -NIP-XX +NIP-C7 ====== Chats From 18c13ca25fdd705726f659dc2069b5042c0552f2 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 20 Nov 2024 11:05:47 -0800 Subject: [PATCH 9/9] Small changes --- 7D.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/7D.md b/7D.md index 5f0e5edff5..d8509a6c25 100644 --- a/7D.md +++ b/7D.md @@ -1,4 +1,4 @@ -NIP-&D +NIP-7D ====== Threads @@ -6,7 +6,7 @@ Threads `draft` `optional` -A thread is a `kind 11` event. Threads SHOULD include a `title` with a summary +A thread is a `kind 11` event. Threads SHOULD include a `subject` with a summary of the thread's topic. ```json @@ -14,7 +14,7 @@ of the thread's topic. "kind": 11, "content": "Good morning", "tags": [ - ["title", "GM"] + ["subject", "GM"] ] } ```