"""N06 to N09: /notifications.""" from uuid import UUID from fastapi import APIRouter, Response from app.common.schemas import Page from app.core.dependencies import CurrentAccount, Db, Paging from app.modules.notifications.schemas import NotificationOut, ReadAllIn, UnreadCount from app.modules.notifications.service import NotificationService router = APIRouter(prefix="/v1", tags=["notifications"]) @router.get("/notifications", response_model=Page[NotificationOut]) async def list_notifications(account: CurrentAccount, db: Db, paging: Paging) -> Page[NotificationOut]: return await NotificationService(db).list(account, paging) @router.get("/notifications/unread-count", response_model=UnreadCount) async def unread_count(account: CurrentAccount, db: Db) -> UnreadCount: return await NotificationService(db).unread_count(account) @router.post("/notifications/read-all", status_code=204) async def read_all(account: CurrentAccount, db: Db, body: ReadAllIn | None = None) -> Response: await NotificationService(db).mark_all_read(account, body.through if body else None) return Response(status_code=204) @router.post("/notifications/{notification_id}/read", status_code=204) async def read_one(notification_id: UUID, account: CurrentAccount, db: Db) -> Response: await NotificationService(db).mark_read(account, notification_id) return Response(status_code=204)