update
This commit is contained in:
@@ -24,6 +24,13 @@ export const atemschutzApi = {
|
||||
);
|
||||
},
|
||||
|
||||
async getByUserId(userId: string): Promise<AtemschutzUebersicht | null> {
|
||||
const response = await api.get<{ success: boolean; data: AtemschutzUebersicht | null }>(
|
||||
`/api/atemschutz/user/${userId}`
|
||||
);
|
||||
return response.data?.data ?? null;
|
||||
},
|
||||
|
||||
async getMyStatus(): Promise<AtemschutzUebersicht | null> {
|
||||
const response = await api.get<{ success: boolean; data: AtemschutzUebersicht | null }>(
|
||||
'/api/atemschutz/my-status'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { api } from './api';
|
||||
import type { NextcloudTalkData, NextcloudConnectData, NextcloudPollData, NextcloudMessage, NextcloudRoomListData } from '../types/nextcloud.types';
|
||||
import type { NextcloudTalkData, NextcloudConnectData, NextcloudPollData, NextcloudMessage, NextcloudRoomListData, NextcloudUser, NextcloudReaction, NextcloudPoll } from '../types/nextcloud.types';
|
||||
|
||||
interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
@@ -57,9 +57,9 @@ export const nextcloudApi = {
|
||||
.then((r) => r.data.data);
|
||||
},
|
||||
|
||||
sendMessage(token: string, message: string): Promise<void> {
|
||||
sendMessage(token: string, message: string, replyTo?: number): Promise<void> {
|
||||
return api
|
||||
.post(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/messages`, { message })
|
||||
.post(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/messages`, { message, ...(replyTo !== undefined ? { replyTo } : {}) })
|
||||
.then(() => undefined);
|
||||
},
|
||||
|
||||
@@ -96,4 +96,40 @@ export const nextcloudApi = {
|
||||
getFilePreviewUrl(fileId: number | string, w = 400, h = 400): string {
|
||||
return `/api/nextcloud/talk/files/${fileId}/preview?w=${w}&h=${h}`;
|
||||
},
|
||||
|
||||
searchUsers(query: string): Promise<NextcloudUser[]> {
|
||||
return api
|
||||
.get<ApiResponse<NextcloudUser[]>>(`/api/nextcloud/talk/users`, { params: { search: query } })
|
||||
.then((r) => r.data.data);
|
||||
},
|
||||
|
||||
createRoom(roomType: number, invite: string, roomName?: string): Promise<{ token: string }> {
|
||||
return api
|
||||
.post<ApiResponse<{ token: string }>>('/api/nextcloud/talk/rooms', { roomType, invite, ...(roomName ? { roomName } : {}) })
|
||||
.then((r) => r.data.data);
|
||||
},
|
||||
|
||||
addReaction(token: string, messageId: number, reaction: string): Promise<void> {
|
||||
return api
|
||||
.post(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/messages/${messageId}/reactions`, { reaction })
|
||||
.then(() => undefined);
|
||||
},
|
||||
|
||||
removeReaction(token: string, messageId: number, reaction: string): Promise<void> {
|
||||
return api
|
||||
.delete(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/messages/${messageId}/reactions`, { params: { reaction } })
|
||||
.then(() => undefined);
|
||||
},
|
||||
|
||||
getReactions(token: string, messageId: number): Promise<Record<string, NextcloudReaction[]>> {
|
||||
return api
|
||||
.get<ApiResponse<Record<string, NextcloudReaction[]>>>(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/messages/${messageId}/reactions`)
|
||||
.then((r) => r.data.data);
|
||||
},
|
||||
|
||||
getPollDetails(token: string, pollId: number): Promise<NextcloudPoll> {
|
||||
return api
|
||||
.get<ApiResponse<NextcloudPoll>>(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/polls/${pollId}`)
|
||||
.then((r) => r.data.data);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user