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

@@ -10,6 +10,8 @@ from app.chats.schemas import (
ChatMemberAddRequest,
ChatMemberRead,
ChatMemberRoleUpdateRequest,
ChatNotificationSettingsRead,
ChatNotificationSettingsUpdate,
ChatPinMessageRequest,
ChatRead,
ChatTitleUpdateRequest,
@@ -22,6 +24,7 @@ from app.chats.service import (
discover_public_chats_for_user,
ensure_saved_messages_chat,
get_chat_for_user,
get_chat_notification_settings_for_user,
get_chats_for_user,
join_public_chat_for_user,
leave_chat_for_user,
@@ -30,6 +33,7 @@ from app.chats.service import (
serialize_chat_for_user,
serialize_chats_for_user,
update_chat_member_role_for_user,
update_chat_notification_settings_for_user,
update_chat_title_for_user,
)
from app.database.session import get_db
@@ -200,3 +204,27 @@ async def pin_chat_message(
) -> ChatRead:
chat = await pin_chat_message_for_user(db, chat_id=chat_id, user_id=current_user.id, payload=payload)
return await serialize_chat_for_user(db, user_id=current_user.id, chat=chat)
@router.get("/{chat_id}/notifications", response_model=ChatNotificationSettingsRead)
async def get_chat_notifications(
chat_id: int,
db: AsyncSession = Depends(get_db),
current_user: User = Depends(get_current_user),
) -> ChatNotificationSettingsRead:
return await get_chat_notification_settings_for_user(db, chat_id=chat_id, user_id=current_user.id)
@router.put("/{chat_id}/notifications", response_model=ChatNotificationSettingsRead)
async def update_chat_notifications(
chat_id: int,
payload: ChatNotificationSettingsUpdate,
db: AsyncSession = Depends(get_db),
current_user: User = Depends(get_current_user),
) -> ChatNotificationSettingsRead:
return await update_chat_notification_settings_for_user(
db,
chat_id=chat_id,
user_id=current_user.id,
payload=payload,
)