update nextcloud handling

This commit is contained in:
Matthias Hochmeister
2026-03-13 12:24:14 +01:00
parent 5f0e76155f
commit e49b4f63ae
5 changed files with 137 additions and 30 deletions

View File

@@ -37,9 +37,23 @@ export const nextcloudApi = {
.then((r) => r.data.data);
},
getMessages(token: string): Promise<NextcloudMessage[]> {
getMessages(
token: string,
options?: { lookIntoFuture?: boolean; lastKnownMessageId?: number; timeout?: number },
signal?: AbortSignal,
): Promise<NextcloudMessage[]> {
const params: Record<string, any> = {};
if (options?.lookIntoFuture) {
params.lookIntoFuture = '1';
params.lastKnownMessageId = options.lastKnownMessageId ?? 0;
params.timeout = options.timeout ?? 25;
}
return api
.get<ApiResponse<NextcloudMessage[]>>(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/messages`)
.get<ApiResponse<NextcloudMessage[]>>(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/messages`, {
params,
signal,
...(options?.lookIntoFuture && { timeout: ((options.timeout ?? 25) + 7) * 1000 }),
})
.then((r) => r.data.data);
},