MSC4140: schedule delayed events through the dedicated endpoint (#5556)
* MSC4140: add dedicated endpoint for delayed events
Use a new, dedicated endpoint for scheduling delayed events.
This should deprecate the `delay` query parameter on the `/send` and
`/state` endpoints.
* Slight optimization of state key usage
* Use `return await` consistently
In methods that were updated to await a promise, don't later directly
return a promise without awaiting it.
* Lint test file
* Split the delayed send out of sendEventHttpRequest
Signed-off-by: Paul Chobert <paul@chobert.fr>
* Align delayed event scheduling with the merged MSC4140 text
On top of the dedicated endpoint from #5133:
- Send the delay as `delay_ms`, keeping the public option named `delay`.
- Put the transaction ID in the path for state events too.
- Keep the MSC4354 sticky duration as a query parameter instead of
spreading it into the JSON body.
- Cache the M_UNRECOGNIZED fallback per client, so the extra round trip
happens once against servers that only know the query parameter;
/versions does not tell the two designs apart.
- Requests giving only `parent_delay_id` go straight to the query
parameter path, since the new body has no equivalent.
Signed-off-by: Paul Chobert <paul@chobert.fr>
* Send the MSC4354 sticky duration in the delayed event request body
MSC4354 now makes the sticky duration a field of the request body on the
dedicated MSC4140 endpoint. It stays a query parameter of the regular
send endpoints, which the M_UNRECOGNIZED fallback still uses.
Signed-off-by: Paul Chobert <paul@chobert.fr>
* Rename the delayed event `delay` option to `delay_ms`
Breaking change: the `delay` option of `SendDelayedEventRequestOpts` is
renamed to `delay_ms`, the name MSC4140 and Synapse use. Callers of
`_unstable_sendDelayedEvent`, `_unstable_sendStickyDelayedEvent` and
`_unstable_sendDelayedStateEvent` must pass `{ delay_ms }` instead of
`{ delay }`.
The query parameter fallback still sends it as `org.matrix.msc4140.delay`.
`DelayedEventInfoItem` keeps its `delay` field: it no longer derives from
the request options, and moving it to the MSC field names is a separate
change.
Signed-off-by: Paul Chobert <paul@chobert.fr>
* Revert the rename of the delayed event `delay` option to `delay_ms`
This reverts commit 79d3cc51e4b26ebdaef3daacf120d8781ec39002.
The rename is a breaking change, which would hold this PR back for the
next breaking release. #5199 changes the same parameter to a plain
number there, so leave the public API to it and keep this PR to the
wire format.
Signed-off-by: Paul Chobert <paul@chobert.fr>
* Allow specifying txnid for delayed state requests
which is now possible since the dedicated delayed event request endpoint
includes a txnid and covers both message & state events.
* Don't ever set sticky duration on delayed state
Since delayed event requests do not allow setting a sticky duration on
state events, prevent ever setting both a state key & a sticky duration
in the body of such a request. (Calling code never did so anyways, but
this change prevents it from ever happening, by simply ignoring the
sticky duration for delayed state events.)
* Rename flag for dedicated delayed endpoint support
Pick a name that avoids a double negation, but still works without
having to invert the flag
* Throw when a delayed state event has a sticky duration
Signed-off-by: Paul Chobert <paul@chobert.fr>
---------
Signed-off-by: Paul Chobert <paul@chobert.fr>
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>