feat(notifications): per-chat mute settings
Some checks failed
CI / test (push) Failing after 18s

- add chat_notification_settings table and migration
- add chat notifications API (get/update muted)
- skip message notifications for muted recipients
- add mute/unmute control in chat info panel
This commit is contained in:
2026-03-08 02:17:09 +03:00
parent eddd4bda0b
commit ea8a50ee05
9 changed files with 238 additions and 3 deletions

View File

@@ -2,6 +2,12 @@ import { http } from "./http";
import type { Chat, ChatDetail, ChatMember, ChatMemberRole, ChatType, DiscoverChat, Message, MessageType } from "../chat/types";
import axios from "axios";
export interface ChatNotificationSettings {
chat_id: number;
user_id: number;
muted: boolean;
}
export async function getChats(query?: string): Promise<Chat[]> {
const { data } = await http.get<Chat[]>("/chats", {
params: query?.trim() ? { query: query.trim() } : undefined
@@ -207,3 +213,13 @@ export async function removeChatMember(chatId: number, userId: number): Promise<
export async function leaveChat(chatId: number): Promise<void> {
await http.post(`/chats/${chatId}/leave`);
}
export async function getChatNotificationSettings(chatId: number): Promise<ChatNotificationSettings> {
const { data } = await http.get<ChatNotificationSettings>(`/chats/${chatId}/notifications`);
return data;
}
export async function updateChatNotificationSettings(chatId: number, muted: boolean): Promise<ChatNotificationSettings> {
const { data } = await http.put<ChatNotificationSettings>(`/chats/${chatId}/notifications`, { muted });
return data;
}