diff options
| -rw-r--r-- | 10.md | 12 | ||||
| -rw-r--r-- | 22.md | 42 | ||||
| -rw-r--r-- | 25.md | 2 | ||||
| -rw-r--r-- | 28.md | 158 | ||||
| -rw-r--r-- | README.md | 9 |
5 files changed, 216 insertions, 7 deletions
| @@ -13,7 +13,7 @@ This NIP describes how to use "e" and "p" tags in text events, especially those | |||
| 13 | ## Positional "e" tags (DEPRECATED) | 13 | ## Positional "e" tags (DEPRECATED) |
| 14 | >This scheme is in common use; but should be considered deprecated. | 14 | >This scheme is in common use; but should be considered deprecated. |
| 15 | 15 | ||
| 16 | `["e", <event-id> <relay-url>]` as per NIP-01. | 16 | `["e", <event-id>, <relay-url>]` as per NIP-01. |
| 17 | 17 | ||
| 18 | Where: | 18 | Where: |
| 19 | 19 | ||
| @@ -26,19 +26,19 @@ Where: | |||
| 26 | This event is not a reply to, nor does it refer to, any other event. | 26 | This event is not a reply to, nor does it refer to, any other event. |
| 27 | 27 | ||
| 28 | * One "e" tag: <br> | 28 | * One "e" tag: <br> |
| 29 | `["e",<id>]`: The id of the event to which this event is a reply. | 29 | `["e", <id>]`: The id of the event to which this event is a reply. |
| 30 | 30 | ||
| 31 | * Two "e" tags: `["e",<root-id>]`, `["e",<reply-id>]` <br> | 31 | * Two "e" tags: `["e", <root-id>]`, `["e", <reply-id>]` <br> |
| 32 | `<root-id>` is the id of the event at the root of the reply chain. `<reply-id>` is the id of the article to which this event is a reply. | 32 | `<root-id>` is the id of the event at the root of the reply chain. `<reply-id>` is the id of the article to which this event is a reply. |
| 33 | 33 | ||
| 34 | * Many "e" tags: `["e",<root-id>]` `["e",<mention-id>]`, ..., `["e",<reply-id>]`<br> | 34 | * Many "e" tags: `["e", <root-id>]` `["e", <mention-id>]`, ..., `["e", <reply-id>]`<br> |
| 35 | There may be any number of `<mention-ids>`. These are the ids of events which may, or may not be in the reply chain. | 35 | There may be any number of `<mention-ids>`. These are the ids of events which may, or may not be in the reply chain. |
| 36 | They are citings from this event. `root-id` and `reply-id` are as above. | 36 | They are citings from this event. `root-id` and `reply-id` are as above. |
| 37 | 37 | ||
| 38 | >This scheme is deprecated because it creates ambiguities that are difficult, or impossible to resolve when an event references another but is not a reply. | 38 | >This scheme is deprecated because it creates ambiguities that are difficult, or impossible to resolve when an event references another but is not a reply. |
| 39 | 39 | ||
| 40 | ## Marked "e" tags (PREFERRED) | 40 | ## Marked "e" tags (PREFERRED) |
| 41 | `["e", <event-id> <relay-url> <marker>]` | 41 | `["e", <event-id>, <relay-url>, <marker>]` |
| 42 | 42 | ||
| 43 | Where: | 43 | Where: |
| 44 | 44 | ||
| @@ -54,7 +54,7 @@ Where: | |||
| 54 | ## The "p" tag | 54 | ## The "p" tag |
| 55 | Used in a text event contains a list of pubkeys used to record who is involved in a reply thread. | 55 | Used in a text event contains a list of pubkeys used to record who is involved in a reply thread. |
| 56 | 56 | ||
| 57 | When replying to a text event E the reply event's "p" tags should contain all of E's "p" tags as well as the `"pubkey"` of the of the event being replied to. | 57 | When replying to a text event E the reply event's "p" tags should contain all of E's "p" tags as well as the `"pubkey"` of the event being replied to. |
| 58 | 58 | ||
| 59 | Example: Given a text event authored by `a1` with "p" tags [`p1`, `p2`, `p3`] then the "p" tags of the reply should be [`a1`, `p1`, `p2`, `p3`] | 59 | Example: Given a text event authored by `a1` with "p" tags [`p1`, `p2`, `p3`] then the "p" tags of the reply should be [`a1`, `p1`, `p2`, `p3`] |
| 60 | in no particular order. | 60 | in no particular order. |
| @@ -0,0 +1,42 @@ | |||
| 1 | NIP-22 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Event `created_at` Limits | ||
| 5 | --------------------------- | ||
| 6 | |||
| 7 | `draft` `optional` `author:jeffthibault` `author:Giszmo` | ||
| 8 | |||
| 9 | Relays may define both upper and lower limits within which they will consider an event's `created_at` to be acceptable. Both the upper and lower limits MUST be unix timestamps in seconds as defined in [NIP-01](01.md). | ||
| 10 | |||
| 11 | If a relay supports this NIP, the relay SHOULD send the client a `NOTICE` message saying the event was not stored for the `created_at` timestamp not being within the permitted limits. | ||
| 12 | |||
| 13 | Client Behavior | ||
| 14 | --------------- | ||
| 15 | |||
| 16 | Clients SHOULD use the [NIP-11](11.md) `supported_nips` field to learn if a relay uses event `created_at` time limits as defined by this NIP. | ||
| 17 | |||
| 18 | Motivation | ||
| 19 | ---------- | ||
| 20 | |||
| 21 | This NIP formalizes restrictions on event timestamps as accepted by a relay and allows clients to be aware of relays that have these restrictions. | ||
| 22 | |||
| 23 | The event `created_at` field is just a unix timestamp and can be set to a time in the past or future. Relays accept and share events dated to 20 years ago or 50,000 years in the future. This NIP aims to define a way for relays that do not want to store events with *any* timestamp to set their own restrictions. | ||
| 24 | |||
| 25 | [Replaceable events](16.md#replaceable-events) can behave rather unexpected if the user wrote them - or tried to write them - with a wrong system clock. Persisting an update with a backdated system now would result in the update not getting persisted without a `NOTICE` and if they did the last update with a forward dated system, they will again fail to do another update with the now correct time. | ||
| 26 | |||
| 27 | A wide adoption of this nip could create a better user experience as it would decrease the amount of events that appear wildly out of order or even from impossible dates in the distant past or future. | ||
| 28 | |||
| 29 | Python Example | ||
| 30 | -------------- | ||
| 31 | |||
| 32 | ```python | ||
| 33 | import time | ||
| 34 | |||
| 35 | TIME = int(time.now) | ||
| 36 | LOWER_LIMIT = TIME - (60 * 60 * 24) # Define lower limit as 1 day into the past | ||
| 37 | UPPER_LIMIT = TIME + (60 * 15) # Define upper limit as 15 minutes into the future | ||
| 38 | |||
| 39 | if event.created_at not in range(LOWER_LIMIT, UPPER_LIMIT): | ||
| 40 | # NOTE: This is one example of a notice message. Relays can change this to notify clients however they like. | ||
| 41 | ws.send('["NOTICE", "The event created_at field is out of the acceptable range (-24h, +15min) for this relay and was not stored."]') | ||
| 42 | ``` | ||
| @@ -7,7 +7,7 @@ Reactions | |||
| 7 | 7 | ||
| 8 | `draft` `optional` `author:jb55` | 8 | `draft` `optional` `author:jb55` |
| 9 | 9 | ||
| 10 | A reaction is a `kind 7` note that is used to react to `kind 1` text notes. | 10 | A reaction is a `kind 7` note that is used to react to other notes. |
| 11 | 11 | ||
| 12 | The generic reaction, represented by the `content` set to a `+` string, SHOULD | 12 | The generic reaction, represented by the `content` set to a `+` string, SHOULD |
| 13 | be interpreted as a "like" or "upvote". | 13 | be interpreted as a "like" or "upvote". |
| @@ -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) | ||
| @@ -18,7 +18,9 @@ NIPs stand for **Nostr Implementation Possibilities**. They exist to document wh | |||
| 18 | - [NIP-14: Subject tag in text events.](14.md) | 18 | - [NIP-14: Subject tag in text events.](14.md) |
| 19 | - [NIP-15: End of Stored Events Notice](15.md) | 19 | - [NIP-15: End of Stored Events Notice](15.md) |
| 20 | - [NIP-16: Event Treatment](16.md) | 20 | - [NIP-16: Event Treatment](16.md) |
| 21 | - [NIP-22: Event created_at Limits](22.md) | ||
| 21 | - [NIP-25: Reactions](25.md) | 22 | - [NIP-25: Reactions](25.md) |
| 23 | - [NIP-28: Public Chat](28.md) | ||
| 22 | 24 | ||
| 23 | ## Event Kinds | 25 | ## Event Kinds |
| 24 | 26 | ||
| @@ -31,6 +33,13 @@ NIPs stand for **Nostr Implementation Possibilities**. They exist to document wh | |||
| 31 | | 4 | Encrypted Direct Messages | 4 | | 33 | | 4 | Encrypted Direct Messages | 4 | |
| 32 | | 5 | Event Deletion | 9 | | 34 | | 5 | Event Deletion | 9 | |
| 33 | | 7 | Reaction | 25 | | 35 | | 7 | Reaction | 25 | |
| 36 | | 40 | Channel Creation | 28 | | ||
| 37 | | 41 | Channel Metadata | 28 | | ||
| 38 | | 42 | Channel Message | 28 | | ||
| 39 | | 43 | Channel Hide Message | 28 | | ||
| 40 | | 44 | Channel Mute User | 28 | | ||
| 41 | | 45-49 | Public Chat Reserved | 28 | | ||
| 42 | |||
| 34 | 43 | ||
| 35 | Please update this list when proposing NIPs introducing new event kinds. | 44 | Please update this list when proposing NIPs introducing new event kinds. |
| 36 | 45 | ||