Skip to content

MSC4140: add dedicated endpoint for delayed events#5133

Open
AndrewFerr wants to merge 4 commits intodevelopfrom
af/msc4140-endpoint
Open

MSC4140: add dedicated endpoint for delayed events#5133
AndrewFerr wants to merge 4 commits intodevelopfrom
af/msc4140-endpoint

Conversation

@AndrewFerr
Copy link
Member

@AndrewFerr AndrewFerr commented Jan 9, 2026

Use a new, dedicated endpoint for scheduling delayed events. This should deprecate the delay query parameter on the /send and /state endpoints.

See:

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.

Use a new, dedicated endpoint for scheduling delayed events.
This should deprecate the `delay` query parameter on the `/send` and
`/state` endpoints.
In methods that were updated to await a promise, don't later directly
return a promise without awaiting it.
Comment on lines +3605 to +3619
// For backwards compatibility with implementations of MSC4140 that
// do not support a dedicated endpoint for adding delayed events
if (!(e instanceof MatrixError && e.errcode === "M_UNRECOGNIZED")) {
throw e;
}
return await this.http.authedRequest(
Method.Put,
utils.encodeUri("/rooms/$roomId/state/$eventType/$stateKey", {
$stateKey: stateKey,
...pathParams,
}),
getUnstableDelayQueryOpts(delayOpts),
content,
opts,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to adapt the MSC to communicate over /versions or /capabilities so as to not need to make 2 calls every time for the majority of servers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using /capabilities is a great idea. I wasn't aware that it allowed custom identifiers.

The MSC already defines a /versions key for whether the feature is enabled or not (which Synapse and the js-sdk make use of), so /capabilities is a good place to put more fine-grained details on the implementation of it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: spec folks have informed me that this is more under the purview of /versions than /capabilities. I'll update the MSC with appropriate new /versions keys before putting them in this PR.

Comment on lines 3060 to 3064
private async sendEventHttpRequest(
event: MatrixEvent,
queryOrDelayOpts?: SendDelayedEventRequestOpts | QueryDict,
queryDict?: QueryDict,
): Promise<ISendEventResponse | SendDelayedEventResponse> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we now separate the two endpoints (delay vs send) I am not sure I am at all happy with this function.

  • We do complicated overloads which are only used to differentiate between the return types (delayId vs eventId)
  • And in the body we then completely split the impl based on the params.

In other words: It all looks to me like there should be sendEventHttpRequest and sendDelayedEventHttpRequest

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how deep we should go. I think encrypt and send event is suffering from the same overload concept. and sendCompleteEvent event as well. Not sure if they both should also be seperate functions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants