-
Notifications
You must be signed in to change notification settings - Fork 379
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
Add rich replies #1617
Add rich replies #1617
Conversation
Fixes matrix-org#1234 The notable parts of this are: * The titles go to insane levels. Rich replies are fairly complex and need some splitting apart to be understandable. * The allowed HTML tags now have an exception for `<mx-reply>` Please note that the event example is intended to be fixed by a PR that fixes all event examples.
better context for the conversation being had. This sort of embedding another | ||
message in a message is known as a "rich reply", or occasionally just a "reply". | ||
|
||
Rich replies may reference another event which also has a rich reply, infinitely. |
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.
can you put this at the end of the paragraph rather than the start? it makes it sound like the rest of the paragraph is going to be about replies which reference replies.
defined is a "rich reply" where a user may reference another message to create a | ||
thread-like conversation. | ||
|
||
Relationships are defined under an ``m.relates_to`` key in the event's ``content``. |
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.
is the structure for this key spelt out anywhere? I'm initially assuming it's an event id but later discovering that it's probably more complicated than that.
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.
it ends up looking like this:
"m.relates_to": {
"m.in_reply_to": {
"event_id": "$thing"
}
}
... will add that in somewhere.
Rich replies may reference another event which also has a rich reply, infinitely. | ||
A rich reply is formed through use of an ``m.relates_to`` relation for ``m.in_reply_to`` | ||
where a single key, ``event_id``, is used to reference the event being replied to. | ||
The referenced event ID MUST belong to the same room where the reply is being sent. |
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.
Sadly it's hard to enforce this sort of thing for events received over federation, so I'd actually soften this to a SHOULD and say that clients should be prepared for it to be otherwise. (likewise the event id being a bad format or indeed any of m.relates_to
having a funny structure).
|
||
Clients that do support rich replies MUST provide the fallback format on replies, | ||
and MUST strip the fallback before rendering the reply. Rich replies MUST supply | ||
a ``format`` of ``org.matrix.custom.html`` and therefore a ``formatted_body`` |
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.
oh now we've baked org.matrix.custom.html
into the spec : (.
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.
(Really we didn't need to, replies easily could have been constructed out of some keys in content instead and worked as plaintext)
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.
@Half-Shot its only required because of the requirement for a fallback, moving stuff into separate keys won't make old clients magically understand it.
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.
In fairness, some clients reject the HTML because of the non-standard weird tag. Also, it's a pain in the arse to parse out the reply text from the bodies so the keys would still have been appreciated.
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.
ftr the baking in happened a long time ago relative to this PR.
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.
And I hate the fact that we are speccing in something that is nasty rather than adding a key and asking client's to adopt it.
I'm all for dropping the fallback on the floor ENTIRELY
the decision was above me
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.
That sounds like a breach of the HTML spec which says you should just ignore invalid tags but not their children?
The IRC bridge (wrongly, imo) assumes that unknown tags mean the rendering will end up looking wierd and falls back to plain.
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.
While I appreciate that the fallback isn't the best case scenario, it's what we have and what we're stuck with for the time being. Clients encounter this format on a regular basis now, and it'll require a bit more effort to fix than we have bandwidth for on this PR. I'd highly recommend an MSC proposing a change.
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.
Fair, not blaming anyone. I just wish we got it right this time around rather than being stuck with it until r0.5
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.
Clients that do support rich replies MUST provide the fallback format on replies, | ||
and MUST strip the fallback before rendering the reply. Rich replies MUST supply | ||
a ``format`` of ``org.matrix.custom.html`` and therefore a ``formatted_body`` | ||
alongside the ``body`` and appropriate ``msgtype``. The specific fall back text |
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.
fallback (no space)
as if rich replies were not special. | ||
|
||
Clients that do support rich replies MUST provide the fallback format on replies, | ||
and MUST strip the fallback before rendering the reply. Rich replies MUST supply |
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.
s/supply/have/
This is where the reply goes | ||
|
||
|
||
The ``formatted_body`` ends up using the following template: |
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.
s/ends up using/should use/ ?
|
||
The related event's ``body`` would be a file name, which may not be very descriptive. | ||
The related event should additionally not have a ``format`` or ``formatted_body`` | ||
in the ``content`` - if the event does, it should be ignored. Because the filename |
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.
"it" == body
? Can you say so?
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.
this is actually describing the format
and formatted_body
- will clarify
Rich replies can only be constructed in the form of ``m.room.message`` events with | ||
a ``msgtype`` of ``m.text`` or ``m.notice``. Due to the fallback requirements, rich | ||
replies cannot be constructed for types of ``m.emote``, ``m.file``, etc. Rich replies | ||
may reference any other ``m.room.message`` event, however. |
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.
well I mean they can't, as you can't provide a nice fallback say if you're replying to a video.
I forgot this was loosened to just text
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.
this is also talking about referencing, not the actual reply itself. It's entirely possible to hit reply on an image, so long as you send text and not another image.
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.
lgtm otherwise
held in the ``content``. | ||
held in the ``content``, like in the following example:: | ||
|
||
{ |
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.
I'm afraid I don't find this example adds any value.
Rendered: see 'docs' status check
This is the spec PR for MSC1234.
Fixes #1234
The notable parts of this are:
<mx-reply>
Please note that the event example is intended to be fixed by a PR that fixes all event examples.