Skip to content

Commit fb1c880

Browse files
committed
Propose method of specifying custom images in reactions
Signed-off-by: Sumner Evans <[email protected]>
1 parent a3778b3 commit fb1c880

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# MSCXXXX Custom Images in Reactions
2+
3+
One of the most desired features within the Matrix ecosystem is the ability to
4+
react to messages with custom images. This feature is especially requested by
5+
users who come from Slack and Discord where this functionality is one of the
6+
main ways that the culture of a chat rooms develops.
7+
8+
There is an existing proposal to
9+
[render image data in reactions (MSC3746)](https://github.com/matrix-org/matrix-spec-proposals/pull/3746/),
10+
but it has had little attention recently and has the flaw of not being conducive
11+
to deduplication (either on the client or server). Sorunome proposed a
12+
modification to that MSC to
13+
[use the MXC URI as the key](https://github.com/matrix-org/matrix-spec-proposals/pull/3746/files#r866285147)
14+
which this proposal adopts.
15+
16+
This proposal is meant to replace
17+
[MSC3746](https://github.com/matrix-org/matrix-spec-proposals/pull/3746/) and is
18+
additionally intended to document the behaviour of existing clients and bridges.
19+
20+
Like
21+
[MSC3746](https://github.com/matrix-org/matrix-spec-proposals/pull/3746/), this
22+
MSC does not propose a mechanism for providing a list of available images.
23+
24+
## Proposal
25+
26+
This proposal suggests two changes to events with the `m.annotation` relation.
27+
28+
1. If the `key` of an `m.annotation` relation is an MXC URI of an image, clients
29+
should render the referenced image instead of the key text.
30+
31+
Detecting if the `key` is an MXC URI can be as sophisticated as the client
32+
wants, but this proposal recommends checking if the string starts with
33+
`mxc://`.
34+
35+
2. When the annotation's key is an MXC URI, a new (optional) `shortcode` key can
36+
be added to the content of the event with a textual name for the image.
37+
38+
This shortcode should be shown by clients in situations such as hovering over
39+
the annotation, as alt-text, or if the client does not support rendering
40+
images.
41+
42+
Example custom image reaction event content
43+
44+
```json
45+
"content": {
46+
"m.relates_to": {
47+
"rel_type": "m.annotation",
48+
"event_id": "$abcdefg",
49+
"key": "mxc://matrix.org/VOczFYqjdGaUKNwkKsTjDwUa"
50+
},
51+
"shortcode": ":partyparrot:"
52+
}
53+
```
54+
55+
## Potential issues
56+
57+
### Clients rendering the MXC URI as text
58+
59+
The biggest disadvantage is that clients that do not support rendering custom
60+
reactions will render the MXC URI as text. However, this is already problematic
61+
because many bridges and clients already support this MSC, and users likely
62+
already encounter this.
63+
64+
### Un-renderable image referenced in the `key`
65+
66+
The MXC URI could specify an asset that either does not exist, or is not a
67+
renderable image. Clients can opt to render the `shortcode` in these situations,
68+
or some placeholder/error image, or just opt to render the full key.
69+
70+
## Alternatives
71+
72+
### Use the shortcode as the `key`
73+
74+
This is what was proposed by
75+
[MSC3746](https://github.com/matrix-org/matrix-spec-proposals/pull/3746/). The
76+
problem with this is that there could possibly be multiple distinct images with
77+
the same shortcode. Reactions are only deduplicated based on `key`, so clients
78+
and servers would group these distinct reactions together which is undesirable.
79+
80+
### Put the `shortcode` as a key within `m.relates_to`
81+
82+
Instead of being at the root of the `content` dictionary, the `shortcode` value
83+
could be included within `m.relates_to`. This is the wrong place to put this
84+
value because `m.relates_to` is meant to only contain information pertaining to
85+
the relationship between events, not information about the reaction event
86+
itself.
87+
88+
## Security considerations
89+
90+
### Image is unencrypted
91+
92+
Reaction events are not encrypted, and so the MXC URI referenced by the key
93+
would have to be an unencrypted image. However, this is probably not a problem
94+
for the following reasons:
95+
96+
- Custom reactions are most likely not sensitive information.
97+
98+
- Users are already able to upload unencrypted content into encrypted rooms, so
99+
this does not introduce any leakage that was not previously possible.
100+
101+
- Clients can add UX to indicate to users that the reaction images are not
102+
encrypted.
103+
104+
## Unstable prefix
105+
106+
Until this proposal is merged into the spec, the `shortcode` key should be
107+
prefixed with `com.beeper.mscXXXX.`.
108+
109+
An unstable prefix for the `key` in `m.relates_to` is not necessary as the spec
110+
already allows arbitrary data to be used as the `key`. This MSC merely adds
111+
extra meaning to a specific class of key.

0 commit comments

Comments
 (0)