From d3bf5a7f45be6a18328c5acdbb23cb90fb84e917 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 23 Sep 2024 10:47:34 -0700 Subject: [PATCH 1/6] 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 5feb91c381f23b7704f01b4655f9147a64afb029 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 24 Sep 2024 16:03:25 -0700 Subject: [PATCH 2/6] 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 0d7ed1e35fbee942c384860e80770ad199697ee3 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 2 Oct 2024 13:17:26 -0700 Subject: [PATCH 3/6] 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 8fbb3b92899c89220098a723a207ec2a883774fd Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 22 Oct 2024 10:54:07 -0700 Subject: [PATCH 4/6] 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 00de1c2db2c41396e034ab370b3cee8949251998 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 28 Oct 2024 14:20:37 -0700 Subject: [PATCH 5/6] 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 60179dfba2a51479c569c9192290bb4cefc660a8 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 18 Nov 2024 06:40:17 -0800 Subject: [PATCH 6/6] 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