Backend: - Notification model + Alembic migration - Notification service: CRUD, mark read, unread count, pending scheduled - WebSocket manager singleton for real-time push - WebSocket endpoint /ws/notifications with JWT auth via query param - APScheduler integration: periodic notification sender (every 60s), daily proactive health review job (8 AM) - AI tool: schedule_notification (immediate or scheduled) - Health review worker: analyzes user memory via Claude, creates ai_generated notifications with WebSocket push Frontend: - Notification API client + Zustand store - WebSocket hook with auto-reconnect (exponential backoff) - Notification bell in header with unread count badge + dropdown - Notifications page with type badges, mark read, mark all read - WebSocket initialized in AppLayout for app-wide real-time updates - Enabled notifications nav in sidebar - English + Russian translations Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
31 lines
655 B
Python
31 lines
655 B
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class NotificationResponse(BaseModel):
|
|
id: uuid.UUID
|
|
user_id: uuid.UUID
|
|
title: str
|
|
body: str
|
|
type: str
|
|
channel: str
|
|
status: str
|
|
scheduled_at: datetime | None
|
|
sent_at: datetime | None
|
|
read_at: datetime | None
|
|
metadata: dict | None = Field(None, alias="metadata_")
|
|
created_at: datetime
|
|
|
|
model_config = {"from_attributes": True, "populate_by_name": True}
|
|
|
|
|
|
class NotificationListResponse(BaseModel):
|
|
notifications: list[NotificationResponse]
|
|
unread_count: int
|
|
|
|
|
|
class UnreadCountResponse(BaseModel):
|
|
count: int
|