diff options
| author | fiatjaf <fiatjaf@gmail.com> | 2024-10-30 17:56:26 -0300 |
|---|---|---|
| committer | fiatjaf <fiatjaf@gmail.com> | 2024-10-30 17:56:26 -0300 |
| commit | 9b6956ddad09534b8fcabdcaea8e8cd106ac8920 (patch) | |
| tree | 78c13dfd7466d027baf8b7e068bbe24983523e5d /37.md | |
| parent | 8e2523e331cbcc7f7247590497a0db607c45cf80 (diff) | |
nip37: optional kind:1 edits.editable
Diffstat (limited to '37.md')
| -rw-r--r-- | 37.md | 59 |
1 files changed, 59 insertions, 0 deletions
| @@ -0,0 +1,59 @@ | |||
| 1 | NIP-37 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Editable Short Notes | ||
| 5 | -------------------- | ||
| 6 | |||
| 7 | `draft` `optional` | ||
| 8 | |||
| 9 | This NIP describes a flow for editing `kind:1` notes that is mostly backwards-compatible (as long as clients support [NIP-09](./09.md) properly). | ||
| 10 | |||
| 11 | The flow for editing a `kind:1` note consists of creating a new `kind:1` note to be published in its place, then issuing a `kind:5` delete request for the first, in both cases attaching special tags that denote the nature of the operation to clients that want to support a more rich edit flow. | ||
| 12 | |||
| 13 | ## Example flow | ||
| 14 | |||
| 15 | Support `<bob>` publishes | ||
| 16 | |||
| 17 | ```jsonc | ||
| 18 | { | ||
| 19 | "id": "aaaaa", | ||
| 20 | "kind": 1, | ||
| 21 | "pubkey": "<bob>", | ||
| 22 | "content": "ehllo" | ||
| 23 | } | ||
| 24 | ``` | ||
| 25 | |||
| 26 | And now, for whatever, reason, he wants to edit the note to say "hello", so his client will publish the following two events: | ||
| 27 | |||
| 28 | ```jsonc | ||
| 29 | { | ||
| 30 | "id": "bbbbbb", | ||
| 31 | "kind": 1, | ||
| 32 | "pubkey": "<bob>", | ||
| 33 | "content": "hello", | ||
| 34 | "tags": [ | ||
| 35 | ["s", "aaaaaa"] // this indicates the note that is being replaced | ||
| 36 | ] | ||
| 37 | } | ||
| 38 | |||
| 39 | { | ||
| 40 | "kind": 5, | ||
| 41 | "pubkey": "<bob>", | ||
| 42 | "tags": [ | ||
| 43 | ["e", "aaaaaa"], // this indicates the note that will be deleted in all non-upgraded clients | ||
| 44 | ["edit", "bbbbbb"], // this indicates the notes that replaced the one just deleted | ||
| 45 | ] | ||
| 46 | } | ||
| 47 | ``` | ||
| 48 | |||
| 49 | ## Backwards-compatibility | ||
| 50 | |||
| 51 | For all non-upgraded clients, this operation will look like a normal delete-and-replace. Replies, likes and everything else sent to node `aaaaaa` will be lost, but the feed will be intact and fine, with no need for any custom handling or complex replaceability. | ||
| 52 | |||
| 53 | ## Progressive enhancement | ||
| 54 | |||
| 55 | Progressive enhancement may be applied, for example: when a user clicks to open note `bbbbbb` the client might try to query for `{"ids": ["aaaaaa"]}` upon seeing the `s` tag. And vice-versa, upon opening any other note a client might query for `{"#s": ["..."]}` to check if any edit is available. Both operations can enhance the focused note screen, but they don't have to be performed while loading a feed, and they remain strictly optional regardless. | ||
| 56 | |||
| 57 | ## Full-blown upgrade | ||
| 58 | |||
| 59 | More complex clients that want to treat edits as pure edits and note as standalone notes may choose to hide any `kind:1` note that contains an `s` tag as a standalone entity, instead choosing to attach it to its "parent" that was edited. That must be combined with a refusal to _actually_ delete notes whenever the `kind:5` deletion request includes an `edit` tag. Such deletion request would then be only used as hints that an edit was performed, so it can be fetched and the note contents replaced in-place. | ||