upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/C7.md
diff options
context:
space:
mode:
Diffstat (limited to 'C7.md')
-rw-r--r--C7.md45
1 files changed, 45 insertions, 0 deletions
diff --git a/C7.md b/C7.md
index 0d94f18..b1e1c8c 100644
--- a/C7.md
+++ b/C7.md
@@ -6,6 +6,12 @@ Chats
6 6
7`draft` `optional` 7`draft` `optional`
8 8
9This NIP describes simple chat messages.
10
11These messages behave like `kind:1` notes syntactically, but are intended to be used in the compĺetely different circumstance of sequential and localized group chats in which ordered consistency is expected, such as, for example, [NIP-29](29.md) rooms, in which a shared relay acts as the (temporary) single source of truth for all the chat messages.
12
13## Definition
14
9A chat message is a `kind 9` event. 15A chat message is a `kind 9` event.
10 16
11```json 17```json
@@ -16,6 +22,8 @@ A chat message is a `kind 9` event.
16} 22}
17``` 23```
18 24
25## Reply
26
19A reply to a `kind 9` is an additional `kind 9` which quotes the parent using a `q` tag. 27A reply to a `kind 9` is an additional `kind 9` which quotes the parent using a `q` tag.
20 28
21```json 29```json
@@ -27,3 +35,40 @@ A reply to a `kind 9` is an additional `kind 9` which quotes the parent using a
27 ] 35 ]
28} 36}
29``` 37```
38
39## Edit
40
41Because these messages are always received in order, an edit can just be another message in the stream that refers to a previous message.
42
43The only difference between an edit and a normal message is that it will have a special `"edit"` tag (and an `EDIT` label prefixing the `content`) that allows clients to optionally parse it as a special edit action and have its changes applied to a previous message in the chat state. For that it uses a simple human-readable text-diff syntax in order to encode a "patch".
44
45Simpler clients that do not want to support this can be just fine with just displaying the edits as normal text messages.
46
47```json
48{
49 "kind": 9,
50 "content": "EDIT\n<patch-content>",
51 "tags": [
52 ["e", <event-id-being-edited>],
53 ["edit"]
54 ]
55}
56```
57
58In which `<patch-content>` is formed by one or more lines of
59
60```
61<index> -<number-of-characters-deleted> +<number-of-characters-inserted> <actual-characters-inserted>
62```
63
64For example, if the original text was `Their should hire more internets to help them` and was edited to `They should hire more interns to help` the patch will be:
65
66```
670 -5 +4 They
6823 -9 +7 interns
6940 -5 +0
70```
71
72The indexes and amounts refer to unicode characters, not bytes.
73
74When generating these diffs clients should prefer to do it over full words instead of over characters, for readability.