1
1
2
2
### Rich replies
3
3
4
- {{% changed-in v="1.3" %}}
5
-
6
4
Rich replies are a
7
5
special kind of [ relationship] ( #forming-relationships-between-events ) which
8
6
effectively quotes the referenced event for the client to render/process how
9
7
it wishes. They are normally used with [ ` m.room.message ` ] ( #mroommessage ) events.
10
8
11
9
{{% boxes/note %}}
10
+ {{% changed-in v="1.3" %}}
12
11
Until v1.3 of the spec, rich replies were limited to ` m.room.message ` events
13
12
which could represent an HTML-formatted body. As of v1.3 this is now expanded
14
13
to * all* event types by dropping the requirement that an HTML-formatted body
@@ -18,9 +17,24 @@ Additionally, a rich reply can reference any other event type as of v1.3.
18
17
Previously, a rich reply could only reference another ` m.room.message ` event.
19
18
{{% /boxes/note %}}
20
19
21
- When possible, events SHOULD include a [ fallback representation] ( #fallbacks-for-rich-replies )
22
- to allow clients which do not render rich replies to still see something which
23
- appears to be a quoted reply.
20
+ {{% boxes/note %}}
21
+ {{% changed-in v="1.13" %}}
22
+ In previous versions of the specification, rich replies could include a fallback
23
+ representation of the original message message in the ` body ` (using a prefix
24
+ sequence) and ` formatted_body ` (using a custom HTML element) for clients that do
25
+ not support rich replies. This is no longer the case, but clients SHOULD still
26
+ remove this fallback before rendering the event.
27
+
28
+ To strip the fallback on the ` body ` , the client should iterate over each
29
+ line of the string, removing any lines that start with the fallback
30
+ prefix sequence (` > ` , including the trailing space) and stopping when
31
+ a line is encountered without the prefix.
32
+
33
+ To strip the fallback on the ` formatted_body ` of an ` m.room.message ` event with
34
+ a ` format ` of ` org.matrix.custom.html ` : if the` formatted_body ` begins with an
35
+ ` <mx-reply> ` start tag, the client should remove the entirety of the
36
+ ` <mx-reply> ` element.
37
+ {{% /boxes/note %}}
24
38
25
39
Though rich replies form a relationship to another event, they do not
26
40
use ` rel_type ` to create this relationship. Instead, a subkey named ` m.in_reply_to `
@@ -48,137 +62,6 @@ An example reply would be:
48
62
Note that the ` event_id ` of the ` m.in_reply_to ` object has the same requirements
49
63
as if it were to be under ` m.relates_to ` directly instead.
50
64
51
- #### Fallbacks for rich replies
52
-
53
- Some clients may not have support for rich replies and therefore need a
54
- fallback to use instead. Clients that do not support rich replies should
55
- render the event as if rich replies were not special.
56
-
57
- Clients that do support rich replies SHOULD provide the fallback format on
58
- replies, and MUST strip the fallback before rendering the reply. The
59
- specific fallback text is different for each ` msgtype ` , however the
60
- general format for the ` body ` is:
61
-
62
- ``` text
63
- > <@alice:example.org> This is the first line of the original body
64
- > This is the second line
65
-
66
- This is where the reply goes
67
- ```
68
-
69
- The ` formatted_body ` , if present and using an associated ` format ` of
70
- ` org.matrix.custom.html ` , should use the following template:
71
-
72
- ``` html
73
- <mx-reply >
74
- <blockquote >
75
- <a href =" https://matrix.to/#/!somewhere:example.org/$event:example.org" >In reply to</a >
76
- <a href =" https://matrix.to/#/@alice:example.org" >@alice:example.org</a >
77
- <br />
78
- <!-- This is where the related event's HTML would be. -->
79
- </blockquote >
80
- </mx-reply >
81
- This is where the reply goes.
82
- ```
83
-
84
- If the related event does not have a ` formatted_body ` , the event's
85
- ` body ` should be considered after encoding any HTML special characters.
86
- Note that the ` href ` in both of the anchors use a [ matrix.to
87
- URI] ( /appendices#matrixto-navigation ) .
88
-
89
- ##### Stripping the fallback
90
-
91
- Clients which support rich replies MUST strip the fallback from the
92
- event before rendering the event. This is because the text provided in
93
- the fallback cannot be trusted to be an accurate representation of the
94
- event. After removing the fallback, clients are recommended to represent
95
- the event referenced by ` m.in_reply_to ` similar to the fallback's
96
- representation, although clients do have creative freedom for their user
97
- interface. Clients should prefer the ` formatted_body ` over the ` body ` ,
98
- just like with other ` m.room.message ` events.
99
-
100
- To strip the fallback on the ` body ` , the client should iterate over each
101
- line of the string, removing any lines that start with the fallback
102
- prefix ("> ; ", including the space, without quotes) and stopping when
103
- a line is encountered without the prefix. This prefix is known as the
104
- "fallback prefix sequence".
105
-
106
- To strip the fallback on the ` formatted_body ` , the client should remove
107
- the entirety of the ` mx-reply ` tag.
108
-
109
- ##### Fallback for ` m.text ` , ` m.notice ` , and unrecognised message types
110
-
111
- Using the prefix sequence, the first line of the related event's ` body `
112
- should be prefixed with the user's ID, followed by each line being
113
- prefixed with the fallback prefix sequence. For example:
114
-
115
- ``` text
116
- > <@alice:example.org> This is the first line
117
- > This is the second line
118
-
119
- This is the reply
120
- ```
121
-
122
- The ` formatted_body ` uses the template defined earlier in this section.
123
-
124
- ##### Fallback for ` m.emote `
125
-
126
- Similar to the fallback for ` m.text ` , each line gets prefixed with the
127
- fallback prefix sequence. However an asterisk should be inserted before
128
- the user's ID, like so:
129
-
130
- ``` text
131
- > * <@alice:example.org> feels like today is going to be a great day
132
-
133
- This is the reply
134
- ```
135
-
136
- The ` formatted_body ` has a subtle difference for the template where the
137
- asterisk is also inserted ahead of the user's ID:
138
-
139
- ``` html
140
- <mx-reply >
141
- <blockquote >
142
- <a href =" https://matrix.to/#/!somewhere:example.org/$event:example.org" >In reply to</a >
143
- * <a href =" https://matrix.to/#/@alice:example.org" >@alice:example.org</a >
144
- <br />
145
- <!-- This is where the related event's HTML would be. -->
146
- </blockquote >
147
- </mx-reply >
148
- This is where the reply goes.
149
- ```
150
-
151
- ##### Fallback for ` m.image ` , ` m.video ` , ` m.audio ` , and ` m.file `
152
-
153
- The related event's ` body ` would be a file name, which may not be very
154
- descriptive. The related event should additionally not have a ` format `
155
- or ` formatted_body ` in the ` content ` - if the event does have a ` format `
156
- and/or ` formatted_body ` , those fields should be ignored. Because the
157
- filename alone may not be descriptive, the related event's ` body ` should
158
- be considered to be ` "sent a file." ` such that the output looks similar
159
- to the following:
160
-
161
- ``` text
162
- > <@alice:example.org> sent a file.
163
-
164
- This is the reply
165
- ```
166
- ``` html
167
- <mx-reply >
168
- <blockquote >
169
- <a href =" https://matrix.to/#/!somewhere:example.org/$event:example.org" >In reply to</a >
170
- <a href =" https://matrix.to/#/@alice:example.org" >@alice:example.org</a >
171
- <br />
172
- sent a file.
173
- </blockquote >
174
- </mx-reply >
175
- This is where the reply goes.
176
- ```
177
-
178
- For ` m.image ` , the text should be ` "sent an image." ` . For ` m.video ` , the
179
- text should be ` "sent a video." ` . For ` m.audio ` , the text should be
180
- ` "sent an audio file" ` .
181
-
182
65
#### Mentioning the replied to user
183
66
184
67
In order to notify users of the reply, it may be desirable to include the ` sender `
0 commit comments