Skip to content

Commit 385bf0b

Browse files
authored
Update MSC3765: Rich text in room topics (#4215)
Updates MSC from feedback,
1 parent f915cc4 commit 385bf0b

File tree

1 file changed

+63
-21
lines changed

1 file changed

+63
-21
lines changed

proposals/3765-rich-room-topics.md

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,52 @@ The wrapping `m.topic` content block is similar to `m.caption` for file
4444
uploads as defined in [MSC3551]. It avoids clients accidentally rendering
4545
the topic state event as a room message.
4646

47+
It is recommended that clients always include a plain text variant when
48+
sending `m.topic` events. This prevents bad UX in situations where a plain
49+
text topic is sufficient such as the public rooms directory.
50+
4751
In order to prevent formatting abuse in room topics, clients are
4852
encouraged to limit the length of topics to at most two lines. Additionally,
4953
clients should ignore things like headings and enumerations (or format them
5054
as regular text). A future MSC may introduce a mechanism to capture extended
5155
multiline details that are not suitable for room topics in a separate field
5256
or event type.
5357

54-
A change to `/_matrix/client/v3/createRoom` is not necessary. The
55-
endpoint has a plain text `topic` parameter but also allows to specify a
56-
full `m.topic` event in `initial_state`.
57-
58-
Room topics also occur as part of the `PublicRoomsChunk` object in the
59-
responses of `/_matrix/client/v3/publicRooms` and
60-
`/_matrix/client/v1/rooms/{roomId}/hierarchy`. The topic can be kept
61-
plain text here because this data should commonly only be displayed to
62-
users that are *not* a member of the room yet. These users will not have
63-
the same need for rich room topics as users who are inside the room. If
64-
no plain text topic exists, home servers should return an empty topic
65-
string from these end points. Since this will inevitably lead to bad UX,
66-
client implementations are encouraged to always include a plain text
67-
variant when sending `m.topic` events.
58+
On the server side, any logic that currently operates on `m.room.topic` is
59+
updated to use `m.topic` instead.
60+
61+
In [`/_matrix/client/v3/createRoom`], the `topic` parameter causes `m.topic`
62+
to be written with a `text/plain` mimetype. If an `m.topic` event is supplied
63+
in `initial_state`, the `topic` parameter overwrites its `text/plain` mimetype
64+
but retains any other mimetypes.
65+
66+
In [`GET /_matrix/client/v3/publicRooms`], [`GET /_matrix/federation/v1/publicRooms`]
67+
and their `POST` siblings, the `topic` response field is read from the
68+
`text/plain` mimetype of `m.topic` if it exists or omitted otherwise.
69+
A plain text topic is sufficient here because this data is commonly
70+
only displayed to users that are *not* a member of the room yet. These
71+
users don't have the same need for rich room topics as users who already
72+
reside in the room.
73+
74+
The same logic is applied to [`/_matrix/client/v1/rooms/{roomId}/hierarchy`]
75+
and [`/_matrix/federation/v1/hierarchy/{roomId}`].
76+
77+
In [server side search], the `room_events` category is expanded to search
78+
over the `text/plain` mimetype in `m.topic`.
79+
80+
Finally, `m.topic` is also added to the events that are recommended for
81+
inclusion in [stripped state].
6882

6983
## Transition
7084

7185
As this MSC replaces `m.room.topic` for an extensible alternative,
7286
clients and servers are expected to treat `m.room.topic` as invalid in
73-
extensible event-supporting room versions.
87+
extensible event-supporting room versions. Similarly, `m.topic` cannot
88+
be used in non-extensible-supporting room versions.
89+
90+
It is recommended that servers replicate `m.room.topic` to `m.topic`
91+
with a plain text mimetype and vice versa when [upgrading] between room
92+
versions that do and don't support extensible events.
7493

7594
## Potential issues
7695

@@ -87,18 +106,41 @@ described in the introductory section of [MSC1767].
87106
## Security considerations
88107

89108
Allowing HTML in room topics is subject to the same security
90-
considerations that apply to HTML in room messages.
109+
considerations that apply to HTML in room messages. In particular,
110+
topics are already included in the content that clients should [sanitise]
111+
for unsafe HTML.
112+
113+
## Other notes
114+
115+
Normally extensible events would only be permitted in a specific
116+
room version. However, to facilitate adoption, clients MAY include
117+
the `m.topic` content block in `m.room.topic` events in room
118+
versions that don't support extensible events. They must, however,
119+
take care to always duplicate the plain text mimetype into the
120+
normal `topic` field, too. This ensures compatibility for clients
121+
and servers that don't support this proposal. Since such clients
122+
are likely to delete the `m.topic` content block when updating
123+
`m.room.topic` themselves, it also helps prevent inconsistencies.
91124

92125
## Unstable prefix
93126

94127
While this MSC is not considered stable, `m.topic` should be referred to
95-
as `org.matrix.msc3765.topic`.
128+
as `org.matrix.msc3765.topic`. Note that extensible events and content
129+
blocks might have their own prefixing requirements.
96130

97131
## Dependencies
98132

99133
- [MSC1767]
100134

101-
[plain text]: https://spec.matrix.org/v1.2/client-server-api/#mroomtopic
102-
[MSC1767]: https://github.com/matrix-org/matrix-spec-proposals/pull/1767
103-
[MSC3551]: https://github.com/matrix-org/matrix-spec-proposals/pull/3551
104-
[`/rooms/{roomId}/upgrade`]: https://spec.matrix.org/v1.5/client-server-api/#post_matrixclientv3roomsroomidupgrade
135+
[plain text]: https://spec.matrix.org/v1.12/client-server-api/#mroomtopic
136+
[MSC1767]: https://github.com/matrix-org/matrix-spec-proposals/pull/1767
137+
[MSC3551]: https://github.com/matrix-org/matrix-spec-proposals/pull/3551
138+
[sanitise]: https://spec.matrix.org/v1.12/client-server-api/#security-considerations
139+
[server side search]: https://spec.matrix.org/v1.12/client-server-api/#server-side-search
140+
[stripped state]: https://spec.matrix.org/v1.12/client-server-api/#stripped-state
141+
[upgrading]: https://spec.matrix.org/v1.12/client-server-api/#room-upgrades
142+
[`/_matrix/client/v1/rooms/{roomId}/hierarchy`]: https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv1roomsroomidhierarchy
143+
[`/_matrix/client/v3/createRoom`]: https://spec.matrix.org/v1.12/client-server-api/#post_matrixclientv3createroom
144+
[`/_matrix/federation/v1/hierarchy/{roomId}`]: https://spec.matrix.org/v1.12/server-server-api/#get_matrixfederationv1hierarchyroomid
145+
[`GET /_matrix/client/v3/publicRooms`]: https://spec.matrix.org/v1.12/client-server-api/#get_matrixclientv3publicrooms
146+
[`GET /_matrix/federation/v1/publicRooms`]: https://spec.matrix.org/v1.12/server-server-api/#get_matrixfederationv1publicrooms

0 commit comments

Comments
 (0)