feat(chat): add presence metadata and improve web chat core
Some checks failed
CI / test (push) Failing after 22s

- add user last_seen_at with alembic migration and persist on realtime disconnect
- extend chat serialization with private online/last_seen, group members/online, channel subscribers
- add Redis batch presence lookup helper
- update web chat list/header to display status counters and last-seen labels
- improve delivery receipt handling using last_delivered/last_read boundaries
- include chat info panel and related API/type updates
This commit is contained in:
2026-03-08 02:02:09 +03:00
parent 51275692ac
commit e6a271f8be
17 changed files with 564 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import { http } from "./http";
import type { Chat, ChatType, DiscoverChat, Message, MessageType } from "../chat/types";
import type { Chat, ChatDetail, ChatMember, ChatMemberRole, ChatType, DiscoverChat, Message, MessageType } from "../chat/types";
import axios from "axios";
export async function getChats(query?: string): Promise<Chat[]> {
@@ -174,3 +174,36 @@ export async function getSavedMessagesChat(): Promise<Chat> {
const { data } = await http.get<Chat>("/chats/saved");
return data;
}
export async function getChatDetail(chatId: number): Promise<ChatDetail> {
const { data } = await http.get<ChatDetail>(`/chats/${chatId}`);
return data;
}
export async function listChatMembers(chatId: number): Promise<ChatMember[]> {
const { data } = await http.get<ChatMember[]>(`/chats/${chatId}/members`);
return data;
}
export async function updateChatTitle(chatId: number, title: string): Promise<Chat> {
const { data } = await http.patch<Chat>(`/chats/${chatId}/title`, { title });
return data;
}
export async function addChatMember(chatId: number, userId: number): Promise<ChatMember> {
const { data } = await http.post<ChatMember>(`/chats/${chatId}/members`, { user_id: userId });
return data;
}
export async function updateChatMemberRole(chatId: number, userId: number, role: ChatMemberRole): Promise<ChatMember> {
const { data } = await http.patch<ChatMember>(`/chats/${chatId}/members/${userId}/role`, { role });
return data;
}
export async function removeChatMember(chatId: number, userId: number): Promise<void> {
await http.delete(`/chats/${chatId}/members/${userId}`);
}
export async function leaveChat(chatId: number): Promise<void> {
await http.post(`/chats/${chatId}/leave`);
}

View File

@@ -19,3 +19,8 @@ export async function updateMyProfile(payload: UserProfileUpdatePayload): Promis
const { data } = await http.put<AuthUser>("/users/profile", payload);
return data;
}
export async function getUserById(userId: number): Promise<AuthUser> {
const { data } = await http.get<AuthUser>(`/users/${userId}`);
return data;
}