Files
mtusi2026lab2/src/messenger/attachments/application/commands.py
T
ArtyomandClaude Opus 5.5 76c9673ab3 Add the attachments zone with its domain and use cases
The zone owns the Attachment aggregate, which is staged as pending with
a server-assigned object key and becomes ready only when stored, the
Filename value that refuses empty, blank, overlong names and names with
a path separator or a control character, and the declared image type.

UploadAttachment checks membership first through the ChatMembership
port, then the name and the declared type, reads the body stream only
up to the limit while hashing it, inspects the image through a port,
commits the pending row, writes the object through the ObjectStorage
port and commits the ready row. GetAttachment and OpenAttachment answer
404 to strangers and to a ready row whose object is gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-28 20:43:41 +03:00

15 lines
350 B
Python

from collections.abc import AsyncIterator
from dataclasses import dataclass
from uuid import UUID
from messenger.shared.application.commands import Command
@dataclass(frozen=True, slots=True)
class UploadAttachment(Command):
owner_id: UUID
chat_id: UUID
filename: str | None
content_type: str | None
body: AsyncIterator[bytes]