Process events list client side
This commit is contained in:
@@ -1,5 +1,70 @@
|
||||
import { APIClient } from "../ApiClient";
|
||||
import type { Room } from "./MatrixApiRoom";
|
||||
|
||||
export interface MatrixRoomMessage {
|
||||
type: "m.room.message";
|
||||
content: {
|
||||
body: string;
|
||||
msgtype: "m.text" | "m.image" | string;
|
||||
"m.relates_to"?: {
|
||||
event_id: string;
|
||||
rel_type: "m.replace" | string;
|
||||
};
|
||||
file?: {
|
||||
url: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface MatrixReaction {
|
||||
type: "m.reaction";
|
||||
content: {
|
||||
"m.relates_to": {
|
||||
event_id: string;
|
||||
key: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface MatrixRoomRedaction {
|
||||
type: "m.room.redaction";
|
||||
redacts: string;
|
||||
}
|
||||
|
||||
export type MatrixEventData =
|
||||
| MatrixRoomMessage
|
||||
| MatrixReaction
|
||||
| MatrixRoomRedaction
|
||||
| { type: "other" };
|
||||
|
||||
export interface MatrixEvent {
|
||||
id: string;
|
||||
time: number;
|
||||
sender: string;
|
||||
data: MatrixEventData;
|
||||
}
|
||||
|
||||
export interface MatrixEventsList {
|
||||
start: string;
|
||||
end?: string;
|
||||
events: MatrixEvent[];
|
||||
}
|
||||
|
||||
export class MatrixApiEvent {
|
||||
/**
|
||||
* Get Matrix room events
|
||||
*/
|
||||
static async GetRoomEvents(
|
||||
room: Room,
|
||||
from?: string
|
||||
): Promise<MatrixEventsList> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "GET",
|
||||
uri:
|
||||
`/matrix/room/${encodeURIComponent(room.id)}/events` +
|
||||
(from ? `?from=${from}` : ""),
|
||||
})
|
||||
).data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user