Skip to content

Add support for delayed event (MSC4140) - #6973

Open
BillCarsonFr wants to merge 4 commits into
mainfrom
valere/delayed-event-api
Open

Add support for delayed event (MSC4140)#6973
BillCarsonFr wants to merge 4 commits into
mainfrom
valere/delayed-event-api

Conversation

@BillCarsonFr

@BillCarsonFr BillCarsonFr commented Sep 3, 2026

Copy link
Copy Markdown
Member

Motivation: I am working on a rust rtc stack https://github.com/BillCarsonFr/matrix-rust-rtc. , and some of the needed primitive are missing in rust-sdk.

I am starting with support of delayed event (state events and room event).
Currently the widget driver had some support for it (by using raw ruma requests), and I am moving it so it became part of the API.

While doing so I noticed that the driver implementation was faulty:

  • It was not encrypting delayed events in encrypted rooms 🥶
  • It was not checking for delayed event support before processing. This is annoying because delaying an event is just adding a query param to the send request, so if the homeserver ignores it there is a risk of sending the delayed event immediatly. Hopefully recent synapse detects that and errors with M_FORBIDDEN: MatrixError: [403] Sending delayed events has been disallowed

A note on the send event future, I cannot just add an optional parameter to SendRawMessageLikeEvent because delayed event returns a delayed_id, and the send event future returns a OwnedEventId
In order to share the encryption code, I created an intermediate future PreparedMessageLikeEvent that handles the common part before the ruma request.
I added a SendRawMessageLikeEvent::with_delay that converts to the new SendDelayedRawMessageLikeEvent future

  • I've documented the public API changes in the appropriate changelog files (see Writing changelog entries).
  • This PR was made with the help of AI.

Signed-off-by:

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.44068% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.23%. Comparing base (7def4e6) to head (cfb09a4).
⚠️ Report is 11 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/room/futures.rs 81.42% 9 Missing and 4 partials ⚠️
crates/matrix-sdk/src/client/mod.rs 75.00% 0 Missing and 2 partials ⚠️
crates/matrix-sdk/src/widget/matrix.rs 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6973   +/-   ##
=======================================
  Coverage   90.23%   90.23%           
=======================================
  Files         408      408           
  Lines      117281   117352   +71     
  Branches   117281   117352   +71     
=======================================
+ Hits       105823   105893   +70     
- Misses       7511     7521   +10     
+ Partials     3947     3938    -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed-hq

codspeed-hq Bot commented Sep 3, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing valere/delayed-event-api (cfb09a4) with main (f4b9512)

Open in CodSpeed

@BillCarsonFr
BillCarsonFr marked this pull request as ready for review September 4, 2026 06:24
@BillCarsonFr
BillCarsonFr requested a review from a team as a code owner September 4, 2026 06:24
@BillCarsonFr
BillCarsonFr requested review from Hywan and removed request for a team September 4, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant