diff --git a/doc/impl-thoughts/PENDING_REPLIES.md b/doc/impl-thoughts/PENDING_REPLIES.md new file mode 100644 index 00000000..4a5e4997 --- /dev/null +++ b/doc/impl-thoughts/PENDING_REPLIES.md @@ -0,0 +1,25 @@ +# Replying to pending messages +The matrix spec requires clients capable of rich replies (that would be us once replies work) to include fallback (textual in `body` and structured in `formatted_body`) that can be rendered +by clients that do not natively support rich replies (that would be us at the time of writing). The schema for the fallback is as follows: + +``` + +
+ In reply to + @alice:example.org +
+ +
+
+``` + +There's a single complication here for pending events: we have `$event:example.org` in the schema (the `In reply to` link), and it must +be present _within the content_, inside `formatted_body`. The issue is that, if we are queuing a reply to a pending event, +we don't know its remote ID. All we know is its transaction ID on our end. If we were to use that while formatting the message, +we'd be sending messages that contain our internal transaction IDs instead of proper matrix event identifiers. + +To solve this, we'd need `SendQueue`, whenever it receives a remote echo, to update pending events that are replies with their +`relatedEventId`. This already happens, and the `event_id` field in `m.relates_to` is updated. But we'd need to extend this +to adjust the messages' `formatted_body` with the resolved remote ID, too. + +How do we safely do this, without accidentally substituting event IDs into places in the body where they were not intended?