Add notification settings
This commit is contained in:
@@ -9,7 +9,8 @@ from app.models.assignment import AssignmentStatus
|
||||
from app.models.marathon import MarathonStatus
|
||||
from app.schemas import (
|
||||
UserPublic, UserPrivate, UserUpdate, TelegramLink, MessageResponse,
|
||||
PasswordChange, UserStats, UserProfilePublic,
|
||||
PasswordChange, UserStats, UserProfilePublic, NotificationSettings,
|
||||
NotificationSettingsUpdate,
|
||||
)
|
||||
from app.services.storage import storage_service
|
||||
|
||||
@@ -189,6 +190,32 @@ async def change_password(
|
||||
return MessageResponse(message="Пароль успешно изменен")
|
||||
|
||||
|
||||
@router.get("/me/notifications", response_model=NotificationSettings)
|
||||
async def get_notification_settings(current_user: CurrentUser):
|
||||
"""Get current user's notification settings"""
|
||||
return NotificationSettings.model_validate(current_user)
|
||||
|
||||
|
||||
@router.patch("/me/notifications", response_model=NotificationSettings)
|
||||
async def update_notification_settings(
|
||||
data: NotificationSettingsUpdate,
|
||||
current_user: CurrentUser,
|
||||
db: DbSession,
|
||||
):
|
||||
"""Update current user's notification settings"""
|
||||
if data.notify_events is not None:
|
||||
current_user.notify_events = data.notify_events
|
||||
if data.notify_disputes is not None:
|
||||
current_user.notify_disputes = data.notify_disputes
|
||||
if data.notify_moderation is not None:
|
||||
current_user.notify_moderation = data.notify_moderation
|
||||
|
||||
await db.commit()
|
||||
await db.refresh(current_user)
|
||||
|
||||
return NotificationSettings.model_validate(current_user)
|
||||
|
||||
|
||||
@router.get("/me/stats", response_model=UserStats)
|
||||
async def get_my_stats(current_user: CurrentUser, db: DbSession):
|
||||
"""Получить свою статистику"""
|
||||
|
||||
Reference in New Issue
Block a user