diff options
| -rw-r--r-- | 28.md | 158 |
1 files changed, 158 insertions, 0 deletions
| @@ -0,0 +1,158 @@ | |||
| 1 | |||
| 2 | NIP-28 | ||
| 3 | ====== | ||
| 4 | |||
| 5 | Public Chat | ||
| 6 | ----------- | ||
| 7 | |||
| 8 | `draft` `optional` `author:ChristopherDavid` `author:fiatjaf` `author:jb55` `author:Cameri` | ||
| 9 | |||
| 10 | This NIP defines new event kinds for public chat channels, channel messages, and basic client-side moderation. | ||
| 11 | |||
| 12 | It reserves five event kinds (40-44) for immediate use and five event kinds (45-49) for future use. | ||
| 13 | |||
| 14 | - `40 - channel create` | ||
| 15 | - `41 - channel metadata` | ||
| 16 | - `42 - channel message` | ||
| 17 | - `43 - hide message` | ||
| 18 | - `44 - mute user` | ||
| 19 | |||
| 20 | Client-centric moderation gives client developers discretion over what types of content they want included in their apps, while imposing no additional requirements on relays. | ||
| 21 | |||
| 22 | ## Kind 40: Create channel | ||
| 23 | |||
| 24 | Create a public chat channel. | ||
| 25 | |||
| 26 | In the channel creation `content` field, Client SHOULD include basic channel metadata (`name`, `about`, `picture` as specified in kind 41). | ||
| 27 | |||
| 28 | ```json | ||
| 29 | { | ||
| 30 | "content": "{\"name\": \"Demo Channel\", \"about\": \"A test channel.\", \"picture\": \"https://placekitten.com/200/200\"}", | ||
| 31 | ... | ||
| 32 | } | ||
| 33 | ``` | ||
| 34 | |||
| 35 | |||
| 36 | ## Kind 41: Set channel metadata | ||
| 37 | |||
| 38 | Update a channel's public metadata. | ||
| 39 | |||
| 40 | Clients and relays SHOULD handle kind 41 events similar to kind 0 `metadata` events. | ||
| 41 | |||
| 42 | Clients SHOULD ignore kind 41s from pubkeys other than the kind 40 pubkey. | ||
| 43 | |||
| 44 | Clients SHOULD support basic metadata fields: | ||
| 45 | |||
| 46 | - `name` - string - Channel name | ||
| 47 | - `about` - string - Channel description | ||
| 48 | - `picture` - string - URL of channel picture | ||
| 49 | |||
| 50 | Clients MAY add additional metadata fields. | ||
| 51 | |||
| 52 | Clients SHOULD use [NIP-10](10.md) marked "e" tags to recommend a relay. | ||
| 53 | |||
| 54 | ```json | ||
| 55 | { | ||
| 56 | "content": "{\"name\": \"Updated Demo Channel\", \"about\": \"Updating a test channel.\", \"picture\": \"https://placekitten.com/201/201\"}", | ||
| 57 | "tags": [["e", <channel_create_event_id> <relay-url>]], | ||
| 58 | ... | ||
| 59 | } | ||
| 60 | ``` | ||
| 61 | |||
| 62 | |||
| 63 | ## Kind 42: Create channel message | ||
| 64 | |||
| 65 | Send a text message to a channel. | ||
| 66 | |||
| 67 | Clients SHOULD use [NIP-10](10.md) marked "e" tags to recommend a relay and specify whether it is a reply or root message. | ||
| 68 | |||
| 69 | Clients SHOULD append [NIP-10](10.md) "p" tags to replies. | ||
| 70 | |||
| 71 | Root message: | ||
| 72 | |||
| 73 | ```json | ||
| 74 | { | ||
| 75 | "content": <string>, | ||
| 76 | "tags": [["e", <kind_40_event_id> <relay-url> "root"]], | ||
| 77 | ... | ||
| 78 | } | ||
| 79 | ``` | ||
| 80 | |||
| 81 | Reply to another message: | ||
| 82 | |||
| 83 | ```json | ||
| 84 | { | ||
| 85 | "content": <string>, | ||
| 86 | "tags": [ | ||
| 87 | ["e", <kind_42_event_id> <relay-url> "reply"], | ||
| 88 | ["p", <pubkey> <relay-url>], | ||
| 89 | ... | ||
| 90 | ], | ||
| 91 | ... | ||
| 92 | } | ||
| 93 | ``` | ||
| 94 | |||
| 95 | |||
| 96 | ## Kind 43: Hide message | ||
| 97 | |||
| 98 | User no longer wants to see a certain message. | ||
| 99 | |||
| 100 | The `content` may optionally include metadata such as a `reason`. | ||
| 101 | |||
| 102 | Clients SHOULD hide event 42s shown to a given user, if there is an event 43 from that user matching the event 42 `id`. | ||
| 103 | |||
| 104 | Clients MAY hide event 42s for other users other than the user who sent the event 43. | ||
| 105 | |||
| 106 | (For example, if three users 'hide' an event giving a reason that includes the word 'pornography', a Nostr client that is an iOS app may choose to hide that message for all iOS clients.) | ||
| 107 | |||
| 108 | ```json | ||
| 109 | { | ||
| 110 | "content": "{\"reason\": \"Dick pic\"}", | ||
| 111 | "tags": [["e", <kind_42_event_id>]], | ||
| 112 | ... | ||
| 113 | } | ||
| 114 | ``` | ||
| 115 | |||
| 116 | ## Kind 44: Mute user | ||
| 117 | |||
| 118 | User no longer wants to see messages from another user. | ||
| 119 | |||
| 120 | The `content` may optionally include metadata such as a `reason`. | ||
| 121 | |||
| 122 | Clients SHOULD hide event 42s shown to a given user, if there is an event 44 from that user matching the event 42 `pubkey`. | ||
| 123 | |||
| 124 | Clients MAY hide event 42s for users other than the user who sent the event 44. | ||
| 125 | |||
| 126 | ```json | ||
| 127 | { | ||
| 128 | "content": "{\"reason\": \"Posting dick pics\"}", | ||
| 129 | "tags": [["p", <pubkey>]], | ||
| 130 | ... | ||
| 131 | } | ||
| 132 | ``` | ||
| 133 | |||
| 134 | ## NIP-10 relay recommendations | ||
| 135 | |||
| 136 | For [NIP-10](10.md) relay recommendations, clients generally SHOULD use the relay URL of the original (oldest) kind 40 event. | ||
| 137 | |||
| 138 | Clients MAY recommend any relay URL. For example, if a relay hosting the original kind 40 event for a channel goes offline, clients could instead fetch channel data from a backup relay, or a relay that clients trust more than the original relay. | ||
| 139 | |||
| 140 | |||
| 141 | Future extensibility | ||
| 142 | -------------------- | ||
| 143 | |||
| 144 | We reserve event kinds 45-49 for other events related to chat, to potentially include new types of media (photo/video), moderation, or support of private or group messaging. | ||
| 145 | |||
| 146 | |||
| 147 | Motivation | ||
| 148 | ---------- | ||
| 149 | If we're solving censorship-resistant communication for social media, we may as well solve it also for Telegram-style messaging. | ||
| 150 | |||
| 151 | We can bring the global conversation out from walled gardens into a true public square open to all. | ||
| 152 | |||
| 153 | |||
| 154 | Additional info | ||
| 155 | --------------- | ||
| 156 | |||
| 157 | - [Chat demo PR with fiatjaf+jb55 comments](https://github.com/ArcadeCity/arcade/pull/28) | ||
| 158 | - [Conversation about NIP16](https://t.me/nostr_protocol/29566) | ||