feat: add annotations, user profiles, watchers, stories, search and more

This commit is contained in:
h
2026-06-01 17:15:09 +02:00
parent ed469ba8dd
commit 2465bcd184
47 changed files with 5009 additions and 242 deletions
+18 -2
View File
@@ -6,12 +6,23 @@ from fastapi import APIRouter, HTTPException, Query
from fastapi.responses import FileResponse
from utils.jobs import enqueue
from utils.read.avatars import current_avatar
from utils.read.avatars import avatar_by_unique_id, avatar_history, current_avatar
from utils.read.models import AvatarHistoryView
from utils.storage import ContentAddressedStorage
router = APIRouter(prefix="/api/avatars", tags=["avatars"], route_class=DishkaRoute)
@router.get("/{owner_kind}/{owner_id}/history")
async def serve_avatar_history(
pool: FromDishka[asyncpg.Pool],
owner_kind: str, # noqa: ARG001
owner_id: int,
account_id: Annotated[int, Query()],
) -> list[AvatarHistoryView]:
return await avatar_history(pool, account_id, owner_id)
@router.get("/{owner_kind}/{owner_id}")
async def serve_avatar(
pool: FromDishka[asyncpg.Pool],
@@ -19,8 +30,13 @@ async def serve_avatar(
owner_kind: str,
owner_id: int,
account_id: Annotated[int, Query()],
unique_id: Annotated[str | None, Query()] = None,
) -> FileResponse:
avatar = await current_avatar(pool, account_id, owner_kind, owner_id)
avatar = (
await avatar_by_unique_id(pool, account_id, owner_id, unique_id)
if unique_id is not None
else await current_avatar(pool, account_id, owner_kind, owner_id)
)
if avatar is None:
raise HTTPException(status_code=404, detail="avatar not found")
if not avatar.downloaded or avatar.storage_key is None: