from datetime import datetime from typing import Literal from uuid import UUID from pydantic import BaseModel from messenger.attachments.domain.models import Attachment class AttachmentOut(BaseModel): id: UUID chat_id: UUID owner_id: UUID filename: str content_type: str size_bytes: int sha256: str status: Literal["ready"] = "ready" variants: tuple[()] = () error_code: None = None created_at: datetime updated_at: datetime @classmethod def of(cls, attachment: Attachment) -> AttachmentOut: return cls( id=attachment.id, chat_id=attachment.chat_id, owner_id=attachment.owner_id, filename=attachment.filename.value, content_type=attachment.content_type, size_bytes=attachment.size_bytes, sha256=attachment.sha256, created_at=attachment.created_at, updated_at=attachment.updated_at, )