Basic WS sync

This commit is contained in:
2025-11-28 17:00:42 +01:00
parent 799341f77c
commit 4b30d67706
4 changed files with 180 additions and 4 deletions

View File

@@ -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 {
/**