diff options
| -rw-r--r-- | 11.md | 4 | ||||
| -rw-r--r-- | 22.md | 45 | ||||
| -rw-r--r-- | README.md | 1 |
3 files changed, 2 insertions, 48 deletions
| @@ -131,9 +131,9 @@ This should only be set to `true` when users are expected to know the relay poli | |||
| 131 | to write to it -- like belonging to a special pubkey-based whitelist or writing only events of | 131 | to write to it -- like belonging to a special pubkey-based whitelist or writing only events of |
| 132 | a specific niche kind or content. Normal anti-spam heuristics, for example, do not qualify. | 132 | a specific niche kind or content. Normal anti-spam heuristics, for example, do not qualify. |
| 133 | 133 | ||
| 134 | - `created_at_lower_limit`: 'created_at' lower limit as defined in [NIP-22](22.md) | 134 | - `created_at_lower_limit`: 'created_at' lower limit |
| 135 | 135 | ||
| 136 | - `created_at_upper_limit`: 'created_at' upper limit as defined in [NIP-22](22.md) | 136 | - `created_at_upper_limit`: 'created_at' upper limit |
| 137 | 137 | ||
| 138 | ### Event Retention | 138 | ### Event Retention |
| 139 | 139 | ||
| @@ -1,45 +0,0 @@ | |||
| 1 | NIP-22 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Event `created_at` Limits | ||
| 5 | ------------------------- | ||
| 6 | |||
| 7 | `draft` `optional` | ||
| 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 an `OK` result 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_ can behave rather unexpectedly 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 notification 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 | Keep in mind that there is a use case where a user migrates their old posts onto a new relay. If a relay rejects events that were not recently created, it cannot serve this use case. | ||
| 30 | |||
| 31 | |||
| 32 | Python (pseudocode) Example | ||
| 33 | --------------------------- | ||
| 34 | |||
| 35 | ```python | ||
| 36 | import time | ||
| 37 | |||
| 38 | TIME = int(time.time()) | ||
| 39 | LOWER_LIMIT = TIME - (60 * 60 * 24) # Define lower limit as 1 day into the past | ||
| 40 | UPPER_LIMIT = TIME + (60 * 15) # Define upper limit as 15 minutes into the future | ||
| 41 | |||
| 42 | if event.created_at not in range(LOWER_LIMIT, UPPER_LIMIT): | ||
| 43 | ws.send('["OK", event.id, False, "invalid: the event created_at field is out of the acceptable range (-24h, +15min) for this relay"]') | ||
| 44 | ``` | ||
| 45 | Note: These are just example limits, the relay operator can choose whatever limits they want. | ||
| @@ -38,7 +38,6 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos | |||
| 38 | - [NIP-18: Reposts](18.md) | 38 | - [NIP-18: Reposts](18.md) |
| 39 | - [NIP-19: bech32-encoded entities](19.md) | 39 | - [NIP-19: bech32-encoded entities](19.md) |
| 40 | - [NIP-21: `nostr:` URI scheme](21.md) | 40 | - [NIP-21: `nostr:` URI scheme](21.md) |
| 41 | - [NIP-22: Event `created_at` Limits](22.md) | ||
| 42 | - [NIP-23: Long-form Content](23.md) | 41 | - [NIP-23: Long-form Content](23.md) |
| 43 | - [NIP-24: Extra metadata fields and tags](24.md) | 42 | - [NIP-24: Extra metadata fields and tags](24.md) |
| 44 | - [NIP-25: Reactions](25.md) | 43 | - [NIP-25: Reactions](25.md) |