Basic WS sync
This commit is contained in:
@@ -1,9 +1,54 @@
|
||||
import { APIClient } from "./ApiClient";
|
||||
|
||||
export type WsMessage = {
|
||||
type: string;
|
||||
[k: string]: any;
|
||||
};
|
||||
interface BaseRoomEvent {
|
||||
time: number;
|
||||
room_id: string;
|
||||
event_id: string;
|
||||
sender: string;
|
||||
origin_server_ts: number;
|
||||
}
|
||||
|
||||
type MessageType = "m.text" | "m.image" | string;
|
||||
|
||||
export interface RoomMessageEvent extends BaseRoomEvent {
|
||||
type: "RoomMessageEvent";
|
||||
data: {
|
||||
msgtype: MessageType;
|
||||
body: string;
|
||||
"m.relates_to"?: {
|
||||
rel_type?: "m.replace" | string;
|
||||
event_id?: string;
|
||||
};
|
||||
"m.new_content"?: {
|
||||
msgtype?: MessageType;
|
||||
body?: string;
|
||||
};
|
||||
file?: { url: string };
|
||||
};
|
||||
}
|
||||
|
||||
export interface RoomReactionEvent extends BaseRoomEvent {
|
||||
type: "RoomReactionEvent";
|
||||
data: {
|
||||
"m.relates_to": {
|
||||
rel_type: string;
|
||||
event_id: string;
|
||||
key: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface RoomRedactionEvent extends BaseRoomEvent {
|
||||
type: "RoomRedactionEvent";
|
||||
data: {
|
||||
redacts: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type WsMessage =
|
||||
| RoomMessageEvent
|
||||
| RoomReactionEvent
|
||||
| RoomRedactionEvent;
|
||||
|
||||
export class WsApi {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user