nips/28.md

154 lines
4.4 KiB
Markdown
Raw Permalink Normal View History

2022-09-10 13:28:08 -04:00
NIP-28
======
Public Chat
-----------
2023-11-15 19:42:51 -05:00
`draft` `optional`
2022-09-10 13:28:08 -04:00
This NIP defines new event kinds for public chat channels, channel messages, and basic client-side moderation.
2023-03-07 05:28:53 -05:00
It reserves five event kinds (40-44) for immediate use:
2022-09-10 13:28:08 -04:00
- `40 - channel create`
- `41 - channel metadata`
- `42 - channel message`
- `43 - hide message`
- `44 - mute user`
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.
## Kind 40: Create channel
Create a public chat channel.
2024-03-28 16:57:00 -04:00
In the channel creation `content` field, Client SHOULD include basic channel metadata (`name`, `about`, `picture` and `relays` as specified in kind 41).
2022-09-10 13:28:08 -04:00
2024-09-03 13:11:31 -04:00
```jsonc
2022-09-10 13:28:08 -04:00
{
2024-03-28 16:57:00 -04:00
"content": "{\"name\": \"Demo Channel\", \"about\": \"A test channel.\", \"picture\": \"https://placekitten.com/200/200\", \"relays\": [\"wss://nos.lol\", \"wss://nostr.mom\"]}",
2024-09-03 13:11:31 -04:00
// other fields...
2022-09-10 13:28:08 -04:00
}
```
## Kind 41: Set channel metadata
Update a channel's public metadata.
2024-06-20 23:52:26 -04:00
Kind 41 is used to update the metadata without modifying the event id for the channel. Only the most recent kind 41 per `e` tag value MAY be available.
2022-09-10 13:28:08 -04:00
Clients SHOULD ignore kind 41s from pubkeys other than the kind 40 pubkey.
Clients SHOULD support basic metadata fields:
- `name` - string - Channel name
- `about` - string - Channel description
- `picture` - string - URL of channel picture
2024-03-28 16:57:00 -04:00
- `relays` - array - List of relays to download and broadcast events to
2022-09-10 13:28:08 -04:00
Clients MAY add additional metadata fields.
Clients SHOULD use [NIP-10](10.md) marked "e" tags to recommend a relay.
2024-09-03 13:11:31 -04:00
```jsonc
2022-09-10 13:28:08 -04:00
{
2024-03-28 16:57:00 -04:00
"content": "{\"name\": \"Updated Demo Channel\", \"about\": \"Updating a test channel.\", \"picture\": \"https://placekitten.com/201/201\", \"relays\": [\"wss://nos.lol\", \"wss://nostr.mom\"]}",
"tags": [["e", <channel_create_event_id>, <relay-url>]],
2024-09-03 13:11:31 -04:00
// other fields...
2022-09-10 13:28:08 -04:00
}
```
## Kind 42: Create channel message
Send a text message to a channel.
Clients SHOULD use [NIP-10](10.md) marked "e" tags to recommend a relay and specify whether it is a reply or root message.
Clients SHOULD append [NIP-10](10.md) "p" tags to replies.
Root message:
2024-09-03 13:11:31 -04:00
```jsonc
2022-09-10 13:28:08 -04:00
{
"content": <string>,
"tags": [["e", <kind_40_event_id>, <relay-url>, "root"]],
2024-09-03 13:11:31 -04:00
// other fields...
2022-09-10 13:28:08 -04:00
}
```
Reply to another message:
2024-09-03 13:11:31 -04:00
```jsonc
2022-09-10 13:28:08 -04:00
{
"content": <string>,
"tags": [
["e", <kind_40_event_id>, <relay-url>, "root"],
["e", <kind_42_event_id>, <relay-url>, "reply"],
["p", <pubkey>, <relay-url>],
2024-09-03 13:11:31 -04:00
// rest of tags...
],
2024-09-03 13:11:31 -04:00
// other fields...
2022-09-10 13:28:08 -04:00
}
```
## Kind 43: Hide message
User no longer wants to see a certain message.
The `content` may optionally include metadata such as a `reason`.
Clients SHOULD hide event 42s shown to a given user, if there is an event 43 from that user matching the event 42 `id`.
Clients MAY hide event 42s for other users other than the user who sent the event 43.
(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.)
2024-09-03 13:11:31 -04:00
```jsonc
2022-09-10 13:28:08 -04:00
{
"content": "{\"reason\": \"Dick pic\"}",
"tags": [["e", <kind_42_event_id>]],
2024-09-03 13:11:31 -04:00
// other fields...
2022-09-10 13:28:08 -04:00
}
```
## Kind 44: Mute user
User no longer wants to see messages from another user.
The `content` may optionally include metadata such as a `reason`.
Clients SHOULD hide event 42s shown to a given user, if there is an event 44 from that user matching the event 42 `pubkey`.
Clients MAY hide event 42s for users other than the user who sent the event 44.
2024-09-03 13:11:31 -04:00
```jsonc
2022-09-10 13:28:08 -04:00
{
"content": "{\"reason\": \"Posting dick pics\"}",
"tags": [["p", <pubkey>]],
2024-09-03 13:11:31 -04:00
// other fields...
2022-09-10 13:28:08 -04:00
}
```
2024-03-28 16:57:00 -04:00
## Relay recommendations
2022-09-10 13:28:08 -04:00
2024-03-28 16:57:00 -04:00
Clients SHOULD use the relay URLs of the metadata events.
2022-09-10 13:28:08 -04:00
2024-03-28 16:57:00 -04:00
Clients MAY use 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.
2022-09-10 13:28:08 -04:00
Motivation
----------
If we're solving censorship-resistant communication for social media, we may as well solve it also for Telegram-style messaging.
We can bring the global conversation out from walled gardens into a true public square open to all.
Additional info
---------------
- [Chat demo PR with fiatjaf+jb55 comments](https://github.com/ArcadeCity/arcade/pull/28)
- [Conversation about NIP16](https://t.me/nostr_protocol/29566)