forked from mtusi2026/mtusi2026lab4
- upload, metadata and download endpoints for PNG/JPEG attachments:
limits before reading and decompression, type by content,
structural integrity check without decoding pixels, safe filename
- write order: pending row with object key -> PUT to S3 -> ready;
per-step DB sessions so no pool connection is held during transfers
- attachment_ids in messages (validation, idempotency hash, history);
whitespace-only text allowed with an attachment (teacher, 2026-10-20)
- migration: attachments and message_attachments tables, text length
CHECK relaxed with NOT VALID
- student tests, fault checks and driver commands for attachments;
rollout profile starts from e1161f7 and checks the commit first
- sync attachments deltas into main specs; rules, AGENTS.md, PLAN.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
563 B
Python
23 lines
563 B
Python
from dataclasses import dataclass
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class MessageFullDTO:
|
|
id: UUID
|
|
chat_id: UUID
|
|
sender_id: UUID
|
|
text: str
|
|
created_at: datetime
|
|
# вложения в порядке отправки; в БД — таблица message_attachments
|
|
attachment_ids: tuple[UUID, ...] = ()
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class MessagePageDTO:
|
|
"""Страница истории чата."""
|
|
|
|
items: tuple[MessageFullDTO, ...]
|
|
next_cursor: str | None
|