SurfSense/surfsense_backend/app/notifications/api/schemas.py
CREDO23 7fb0707933 refactor(backend): rename search_space -> workspace across app bulk (Phase 2 Wave D)
Scoped codemod over surfsense_backend/app (excluding routes/, Wave E): renames
search_space_id -> workspace_id, search_space -> workspace, SearchSpace -> Workspace
across services, utils, tasks, agents, gateway, event_bus, notifications, podcasts,
automations, observability params, and prompt .md files. Also flips the camelCase
payload key searchSpaceId -> workspaceId (no backend reader; hard cutover).

Preserved carve-outs (verbatim): Celery task names "delete_search_space_background"
and "ai_sort_search_space" (wire names), and the OTel/metric key "search_space.id"
(dashboards depend on it). Enum values 'SEARCH_SPACE' and SearchSourceConnector
untouched.
2026-06-26 18:30:47 +02:00

81 lines
1.6 KiB
Python

"""Response shapes for the notifications API."""
from __future__ import annotations
from pydantic import BaseModel
class NotificationResponse(BaseModel):
"""A single notification."""
id: int
user_id: str
workspace_id: int | None
type: str
title: str
message: str
read: bool
metadata: dict
created_at: str
updated_at: str | None
class Config:
from_attributes = True
class NotificationListResponse(BaseModel):
"""A page of notifications."""
items: list[NotificationResponse]
total: int
has_more: bool
next_offset: int | None
class MarkReadResponse(BaseModel):
"""Outcome of marking one notification read."""
success: bool
message: str
class MarkAllReadResponse(BaseModel):
"""Outcome of marking every notification read."""
success: bool
message: str
updated_count: int
class SourceTypeItem(BaseModel):
"""A source type with its category and count."""
key: str
type: str
category: str # "connector" or "document"
count: int
class SourceTypesResponse(BaseModel):
"""Source types available for the Status tab filter."""
sources: list[SourceTypeItem]
class UnreadCountResponse(BaseModel):
"""Unread totals, split by sync-window recency."""
total_unread: int
recent_unread: int
class CategoryUnreadCount(BaseModel):
total_unread: int
recent_unread: int
class BatchUnreadCountResponse(BaseModel):
"""Per-category unread counts in one response."""
comments: CategoryUnreadCount
status: CategoryUnreadCount