Skip to content

Commit fa2591c

Browse files
committed
Support MSC4140: Delayed events (Futures)
Widget changes require matrix-org/matrix-widget-api#90
1 parent 94e393c commit fa2591c

File tree

4 files changed

+419
-32
lines changed

4 files changed

+419
-32
lines changed

src/@types/requests.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
import { EitherAnd } from "matrix-events-sdk/lib/types";
18+
1719
import { IContent, IEvent } from "../models/event";
1820
import { Preset, Visibility } from "./partials";
1921
import { IEventWithRoomId, SearchKey } from "./search";
@@ -76,6 +78,52 @@ export interface ISendEventResponse {
7678
event_id: string;
7779
}
7880

81+
export interface IFutureGroupId {
82+
future_group_id: string;
83+
}
84+
85+
export interface IFutureTimeout {
86+
future_timeout: number;
87+
}
88+
89+
export type ISendFutureRequestOpts = EitherAnd<IFutureGroupId, IFutureTimeout>;
90+
91+
export interface IFutureTokens {
92+
send_token: string;
93+
cancel_token: string;
94+
}
95+
96+
export interface ITimeoutFutureTokens extends IFutureTokens {
97+
refresh_token: string;
98+
}
99+
100+
export type ISendActionFutureResponse = IFutureGroupId & IFutureTokens;
101+
export type ISendTimeoutFutureResponse = IFutureGroupId & ITimeoutFutureTokens;
102+
103+
export type ISendFutureResponse<F extends ISendFutureRequestOpts> = F extends IFutureTimeout
104+
? ISendTimeoutFutureResponse
105+
: ISendActionFutureResponse;
106+
107+
export interface ISendFutureGroupResponse {
108+
send_on_timeout: ITimeoutFutureTokens;
109+
send_on_action?: {
110+
[action_name: string]: IFutureTokens;
111+
};
112+
send_now?: ISendEventResponse;
113+
}
114+
115+
interface IFuturePartialEvent {
116+
room_id: string;
117+
type: string;
118+
state_key?: string;
119+
content: IContent;
120+
}
121+
122+
export type IActionFutureInfo = IFutureGroupId & IFuturePartialEvent & IFutureTokens;
123+
export type ITimeoutFutureInfo = IFutureGroupId & IFutureTimeout & IFuturePartialEvent & ITimeoutFutureTokens;
124+
125+
export type IFutureInfo = IActionFutureInfo | ITimeoutFutureInfo;
126+
79127
export interface IPresenceOpts {
80128
// One of "online", "offline" or "unavailable"
81129
presence: "online" | "offline" | "unavailable";

0 commit comments

Comments
 (0)