family update
This commit is contained in:
@@ -667,6 +667,9 @@ export interface ChatMessage {
|
||||
mimeType?: string;
|
||||
metadataJson?: string;
|
||||
createdAt: string;
|
||||
editedAt?: string;
|
||||
isDeleted?: boolean;
|
||||
readByAll?: boolean;
|
||||
poll?: {
|
||||
id: string;
|
||||
question: string;
|
||||
@@ -676,14 +679,37 @@ export interface ChatMessage {
|
||||
};
|
||||
}
|
||||
|
||||
export interface FamilyPresenceMember {
|
||||
userId: string;
|
||||
displayName: string;
|
||||
online: boolean;
|
||||
lastSeenAt?: string;
|
||||
}
|
||||
|
||||
export interface FamilyPresence {
|
||||
members: FamilyPresenceMember[];
|
||||
onlineCount: number;
|
||||
}
|
||||
|
||||
export interface ChatRoomMember {
|
||||
id: string;
|
||||
userId: string;
|
||||
displayName: string;
|
||||
hasAvatar: boolean;
|
||||
notificationsMuted: boolean;
|
||||
familyRole?: string;
|
||||
isChatCreator?: boolean;
|
||||
}
|
||||
|
||||
export interface ChatRoom {
|
||||
id: string;
|
||||
groupId: string;
|
||||
type: string;
|
||||
name: string;
|
||||
hasAvatar: boolean;
|
||||
createdById?: string;
|
||||
updatedAt: string;
|
||||
members: Array<{ id: string; userId: string; displayName: string; hasAvatar: boolean; notificationsMuted: boolean }>;
|
||||
members: ChatRoomMember[];
|
||||
lastMessage?: ChatMessage;
|
||||
}
|
||||
|
||||
@@ -738,6 +764,21 @@ export async function createChatRoom(groupId: string, name: string, memberUserId
|
||||
}, token);
|
||||
}
|
||||
|
||||
export async function addChatRoomMember(roomId: string, memberUserId: string, token?: string | null) {
|
||||
return apiFetch<ChatRoom>(`/chat/rooms/${roomId}/members`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ memberUserId })
|
||||
}, token);
|
||||
}
|
||||
|
||||
export async function removeChatRoomMember(roomId: string, memberUserId: string, token?: string | null) {
|
||||
return apiFetch<ChatRoom>(`/chat/rooms/${roomId}/members/${memberUserId}`, { method: 'DELETE' }, token);
|
||||
}
|
||||
|
||||
export async function removeFamilyMember(memberId: string, token?: string | null) {
|
||||
return apiFetch<{ count: number }>(`/family/members/${memberId}`, { method: 'DELETE' }, token);
|
||||
}
|
||||
|
||||
export async function fetchChatMessages(roomId: string, token?: string | null, beforeMessageId?: string) {
|
||||
const query = beforeMessageId ? `?beforeMessageId=${beforeMessageId}` : '';
|
||||
return apiFetch<{ messages?: ChatMessage[] }>(`/chat/rooms/${roomId}/messages${query}`, {}, token);
|
||||
@@ -767,5 +808,24 @@ export async function setChatRoomMuted(roomId: string, muted: boolean, token?: s
|
||||
return apiFetch(`/chat/rooms/${roomId}/mute`, { method: 'POST', body: JSON.stringify({ muted }) }, token);
|
||||
}
|
||||
|
||||
export async function editChatMessage(messageId: string, content: string, token?: string | null) {
|
||||
return apiFetch<ChatMessage>(`/chat/messages/${messageId}`, { method: 'PATCH', body: JSON.stringify({ content }) }, token);
|
||||
}
|
||||
|
||||
export async function deleteChatMessage(messageId: string, token?: string | null) {
|
||||
return apiFetch<ChatMessage>(`/chat/messages/${messageId}`, { method: 'DELETE' }, token);
|
||||
}
|
||||
|
||||
export async function markChatRoomRead(roomId: string, lastMessageId: string | undefined, token?: string | null) {
|
||||
return apiFetch<{ count: number }>(`/chat/rooms/${roomId}/read`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ lastMessageId })
|
||||
}, token);
|
||||
}
|
||||
|
||||
export async function fetchFamilyPresence(groupId: string, token?: string | null) {
|
||||
return apiFetch<FamilyPresence>(`/family/groups/${groupId}/presence`, {}, token);
|
||||
}
|
||||
|
||||
/** @deprecated Используйте getWsUrl() — URL может переключаться на same-origin /idp-api/ws в браузере */
|
||||
export const WS_URL = configuredWsUrl;
|
||||
|
||||
Reference in New Issue
Block a user