File size: 3,484 Bytes
d40e568
 
 
 
 
 
b6ae8c3
d40e568
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

### Rich replies

Rich replies are a
special kind of [relationship](#forming-relationships-between-events) which
effectively quotes the referenced event for the client to render/process how
it wishes. They are normally used with [`t.room.message`](#troommessage) events.

{{% boxes/note %}}
{{% changed-in v="1.3" %}}
Until v1.3 of the spec, rich replies were limited to `t.room.message` events
which could represent an HTML-formatted body. As of v1.3 this is now expanded
to *all* event types by dropping the requirement that an HTML-formatted body
be included.

Additionally, a rich reply can reference any other event type as of v1.3.
Previously, a rich reply could only reference another `t.room.message` event.
{{% /boxes/note %}}

#### Replies never copy the original

A reply refers to the event it answers **only by event ID**. Clients MUST NOT
copy any part of the original event into a reply: no reply fallback in `body`
or `formatted_body`, no `<mx-reply>` element, no quoted text, no media
reference, and no other content of the original. Clients render the quote
from the original event itself.

This keeps deletion and retention meaningful. When the original is redacted
or expires, its quote disappears from every reply, instead of living on in
other people's messages.

{{% boxes/rationale %}}
Quoting fallbacks were the main way redacted text survived in Matrix: every
reply carried a verbatim copy of the message it answered, readable long after
the original was redacted.
{{% /boxes/rationale %}}

Clients MUST strip any reply fallback they find in a received event before
rendering it. In `body`, remove leading lines that start with `> ` (including
the trailing space), stopping at the first line without the prefix. In a
`formatted_body` with `format` `org.matrix.custom.html`, remove a leading
`<mx-reply>` element entirely.

Though rich replies form a relationship to another event, they do not
use `rel_type` to create this relationship. Instead, a subkey named `t.in_reply_to`
is used to describe the reply's relationship, leaving the other properties of
`t.relates_to` to describe the primary relationship of the event. This means
that if an event is simply in reply to another event, without further relationship,
the `rel_type` and `event_id` properties of `t.relates_to` become *optional*.

An example reply would be:

```json
{
  "content": {
    "t.relates_to": {
      "t.in_reply_to": {
        "event_id": "$another_event"
      }
    },
    "body": "That sounds like a great idea!"
  },
  // other fields as required by events
}
```

Note that the `event_id` of the `t.in_reply_to` object has the same requirements
as if it were to be under `t.relates_to` directly instead.

#### Mentioning the replied to user

{{% boxes/note %}}
{{% changed-in v="1.16" %}}
Clients SHOULD no longer propagate mentioned users in the replied to event.
{{% /boxes/note %}}

In order to notify users of the reply, it MAY be desirable to include the `sender`
of the replied to event. See [user and room mentions](#user-and-room-mentions) for
additional information.

An example including mentioning the original sender:

```json
{
  "content": {
    "t.relates_to": {
      "t.in_reply_to": {
        "event_id": "$another_event"
      }
    },
    "body": "That sounds like a great idea!",
    "t.mentions": {
      "user_ids": [
        // The sender of $another_event.
        "@alice:example.org",
      ]
    }
  },
  // other fields as required by events
}
```