Open wmwsagara opened 1 year ago
First off, if it's a change proposal, please be so kind to use the process described at https://spec.matrix.org/proposals/ - especially, take time to read section 2 and follow the steps from section 3.
As a piece of early feedback to your suggestion - it implies that m.room.message
events can be rendered differently as the time goes. It is a significant leap from their current static nature, and the protocol is not well-equipped to support this. For one, there's no mechanism to notify clients that they have to refresh a certain message, except message edits - and edits already come with new content anyway. There are also social problems, e.g. if a room changes its avatar to an abusive image, the author of the message with "variables" does not necessarily have anything to do with that, yet an abusive image is shown next to that author's name. So it's much more complicated, and you'll have to consider such things in your MSC.
That being said, I think the direction is certainly interesting, and I can see value in presenting dynamic content in the timeline, as long as its dynamic nature is expected. There are precedents of such MSCs: polls and location sharing, for example. It's just that m.room.message
might not be the best place for such things.
@KitsuneRal
I'm afraid I don't really have a clear concept that I could come up with; and also don't really have time to work one out, sorry.
Please note, this is Matrix specification extend proposal. Referring to: https://spec.matrix.org/v1.5/client-server-api/#mtext
Problem: The formatted_body field for m.text message type can carry HTML for a richer rendering of a message.
But room avatar image, room name and number of subscribers for a room are dynamic and can be different by the time one see or see again a message.
Therefore, poster of a message, should not use APIs to fetch what is valid at time of posting and format the formatted_body accordingly.
Instead embed a special tag and leave it for a client to parse the formatted_body, fetch such info, and re-format the formatted_body before present to a user.
Proposal: Here is a proposal for a client to fetch information from a Matrix server by parsing the formatted_body and replace specific embeded tags with relevant info/image url.
Everytime the user refresh the browser or after elaps a certain TTL, the client can re-fetch the info and redisplay in line with the current state.
1.
<MatrixRoomAvatar>
- Fetch room avatar image<MatrixRoomAvatar roomId="xyz" width="w" height="h">
. The w and h are in pixels as per the Matrix thumbnails guide.Fetch the current mxc image id for the room avatar and replace the tag with following:
<img src=mxc://matrix.domain.com/<mxc image id> width=\"w\" height=\"h\">
Eg.
<MatrixRoomAvatar roomId="xyz" width="96" height="96">
replaces with following:<img src=mxc://matrix.domain.com/ROQTHOfYepkTdqdFZtnpiKfG width=\"96\" height=\"96\">
Thumbnails guide: https://spec.matrix.org/v1.5/client-server-api/#thumbnails
2.
<MatrixRoomName>
- Fetch room display name<MatrixRoomName roomId="xyz">
Fetch the current room display name by the room id and replace the tag with current room display name. No formatting, text only.
3.
<MatrixRoomSubscribers>
- Fetch number of subscribers for the room<MatrixRoomSubscribers roomId="xyz" format="9,999,999">
The format attribute is optional.
Fetch the current number of subscribers by the room id and replace the
<MatrixRoomSubscribers>
tag with the number with optional formatting.No format attribute, replace the tag in text without any other formatting as 1234567.
With
format="9,999,999"
, replace the tag in text without any other formatting but with comma formatted. Eg. 1,234,5674.
<MatrixMsgTimeSince>
- Display time elapsed from post creation time<MatrixMsgTimeSince format="t1 t2">
The format attribute is optional. t1 > t2.
Format the "age" parameter as follows: 5s - 5 seconds elapsed after create the post. 2m - 2 minutes elapsed after create the post. 1d - 1 day elapsed after create the post. 2w - 2 weeks elapsed after create the post. 1m - 1 month elapsed after create the post. 1y - 1 year elapsed after create the post.
No format attribute, replace the tag in text without any other formatting in one time unit: Eg. 2m
With
format="t1 t2"
, replace the tag in text without any other formatting in highest two time units. Eg. 1m 5d In above example t1 is 1m and t2 is 5d.Example: Following embeded tags in the HTML code in formatted_body render as the image below:
Hopefully others may suggest other useful Matrix variables.