-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSC3746: Render image data in reactions #3746
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,77 @@ | ||||||
# MSC3746: Render Images in Reactions | ||||||
|
||||||
Many messaging services such as Slack and Discord allow for custom images for reacts, rather than only standard emoji. Currently Element will only show the plain text of the reaction key. In order to achieve parity with other messaging services and satisfy customer needs, we must implement a way to have reactions which can be any image, rather than one of the unicode emojis. | ||||||
|
||||||
This proposal is concerned only with providing an event format which can describe image reactions. Any way for users to compose and send these reactions such as pickers and image packs is out of scope. | ||||||
|
||||||
## Proposal | ||||||
|
||||||
Currently, reactions are implemented as room events which have a relationship with the event they are reacting to. Identical reactions by different users are grouped together by the reaction key, and the reaction key (text/emoji) is displayed under the related message. | ||||||
|
||||||
An example of a reaction, which displays 😀 | ||||||
```json | ||||||
{ | ||||||
"type": "m.reaction", | ||||||
"sender": "@testme:localhost:8008", | ||||||
"content": { | ||||||
"m.relates_to": { | ||||||
"rel_type": "m.annotation", | ||||||
"event_id": "$hPRRsFL03pNRE2tnmzzqyP6OXofz-bbsrQbRWJDA4p0", | ||||||
"key": "😀" | ||||||
} | ||||||
}, | ||||||
"origin_server_ts": 1645830754708, | ||||||
"unsigned": { | ||||||
"age": 28, | ||||||
"transaction_id": "m1645830754585.0" | ||||||
}, | ||||||
"event_id": "$8dZO0nnIoz-uWyDfevNcaGcg5p6e7oK7CoKOwe-aWTM", | ||||||
"room_id": "!uLFjhtpHuebWoCiyvz:localhost:8008" | ||||||
} | ||||||
``` | ||||||
|
||||||
In order to describe a reaction with an image, we simply include an mxc url and optionally [ImageInfo](https://github.com/matrix-org/matrix-doc/blob/f8b83b7fb1194ab48ee3461185c4764ebbfecc68/data/event-schemas/schema/core-event-schema/msgtype_infos/image_info.yaml) in the event content | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Perhaps this should state that the m.image spec is to be mirrored here. As commented elsewhere, optionally(?) including In what regard is ImageInfo useful to have here? Does any client implement it at this point? Maybe file type. |
||||||
|
||||||
content of an image reaction: | ||||||
```json | ||||||
"content": { | ||||||
"m.relates_to": { | ||||||
"rel_type": "m.annotation", | ||||||
"event_id": "$hPRRsFL03pNRE2tnmzzqyP6OXofz-bbsrQbRWJDA4p0", | ||||||
"key": "😀" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wanting to point out that the name identifier of emotes, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with this. I think that the fallback should be in a "content": {
"m.relates_to": {
"rel_type": "m.annotation",
"event_id": "$abcdefg",
"key": "mxc://matrix.org/VOczFYqjdGaUKNwkKsTjDwUa"
},
"shortcode": ":partyparrot:",
"info": {
// same
}
} For the record, Beeper has been doing this with our Slack and Discord bridges for a while now, and it works well. The downside is that the fallback is annoying for clients that don't support it, but that's better than having reactions incorrectly grouped. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We’ve also implemented this approach in Cinny [1]. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this is related to images, wouldn't it make sense to adhere to using the Is it worth stating in spec that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have created #4027 which intends to document what the implementations that already exist do. |
||||||
}, | ||||||
"url": "mxc://matrix.org/VOczFYqjdGaUKNwkKsTjDwUa", | ||||||
"info": { | ||||||
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if any considerations in hindsight to MSC2545: Image Packs make sense, I suppose it could easily get tacked on in hindsight. E.g. |
||||||
"w": 256, | ||||||
"h": 256, | ||||||
"size": 214537, | ||||||
"mimetype": "image/png", | ||||||
"thumbnail_url": "mxc://matrix.org/VOczFYqjdGaUKNwkKsTjDwUa", | ||||||
"thumbnail_info": { | ||||||
"w": 256, | ||||||
"h": 256, | ||||||
"size": 214537, | ||||||
"mimetype": "image/png" | ||||||
} | ||||||
} | ||||||
} | ||||||
``` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the following process should be stated in order to define how to interpret these extended reaction events:
|
||||||
|
||||||
### Server side aggregation | ||||||
Server side aggregation will remain unchanged, where only the keys and counts of those keys are aggregated. In the case where the client is unable to use client-side aggregation and must display reactions based on the server-side aggregation, then it will fallback to displaying only the key for reactions. | ||||||
|
||||||
Element web and desktop do not make use of server-side aggregation for reactions, so they are currently unaffected by this. | ||||||
|
||||||
### Fallback | ||||||
Older clients will simply display the reaction emoji or plaintext. If an older client also clicks the reaction, it will send a reaction event without the image content. Other clients must check all aggregated events to find which ones include the image. If all newer clients unreact, then the image will be lost and the reaction will revert to plaintext/emoji. | ||||||
|
||||||
## Potential issues | ||||||
|
||||||
It's possible that different users will send reactions with different images under the same reaction key, either due to malicious action or collisions. Reaction senders must take this into account and use a key that will not collide with previously existing reactions. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be difficult for clients to ensure that they use a key that does not collide with other reactions. Would it be sufficient to tell clients to send reactions using a key that conveys a similar meaning to the image? In that way, clients that use the server-side aggregations will (as mentioned above) fall back to displaying only the key, so they won't be affected by collisions since they won't display the images. And clients that don't use server-side aggregations will see the full events, and be able to distinguish the reactions based on the |
||||||
|
||||||
This would remove the chance of mismatches between key and image, but would not give an experience to older clients. | ||||||
|
||||||
## Alternatives | ||||||
|
||||||
Instead of including the image information in the event content, we could include everything necessary in the relation key. For example the key could be an mxc url, json, markdown, or reference to an external data source (such as an image set-as-room). | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap your lines to ~80 to ~120 characters.