You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-16 09:42:23 +03:00
MSC4140: support filters on delayed event lookup (#5038)
* MSC4140: support filters on delayed event lookup Support looking up scheduled/finalised delayed events, and looking up a single delayed event. * Add test coverage for delayed event lookup filters * Prettier * Use it.each for test loop * Support multiple delayIds * Support single or multiple delayIds As it may be more common to look up a single delayed event than to look up many of them, support passing a single delayID in the lookup function instead of needing to pass a single-element array.
This commit is contained in:
committed by
GitHub
parent
502a513b5b
commit
2731e20893
@@ -3537,13 +3537,17 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all pending delayed events for the calling user.
|
||||
* Get information about delayed events owned by the requesting user.
|
||||
*
|
||||
* Note: This endpoint is unstable, and can throw an `Error`.
|
||||
* Check progress on [MSC4140](https://github.com/matrix-org/matrix-spec-proposals/pull/4140) for more details.
|
||||
*/
|
||||
// eslint-disable-next-line
|
||||
public async _unstable_getDelayedEvents(fromToken?: string): Promise<DelayedEventInfo> {
|
||||
public async _unstable_getDelayedEvents(
|
||||
status?: "scheduled" | "finalised",
|
||||
delayId?: string | string[],
|
||||
fromToken?: string,
|
||||
): Promise<DelayedEventInfo> {
|
||||
if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
|
||||
throw new UnsupportedDelayedEventsEndpointError(
|
||||
"Server does not support the delayed events API",
|
||||
@@ -3551,7 +3555,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
);
|
||||
}
|
||||
|
||||
const queryDict = fromToken ? { from: fromToken } : undefined;
|
||||
const queryDict = {
|
||||
from: fromToken,
|
||||
status,
|
||||
delay_id: delayId,
|
||||
};
|
||||
return await this.http.authedRequest(Method.Get, "/delayed_events", queryDict, undefined, {
|
||||
prefix: `${ClientPrefix.Unstable}/${UNSTABLE_MSC4140_DELAYED_EVENTS}`,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user