2026-07-17 23:20:34 +02:00
|
|
|
"""Compose/draft/send request & response models (SPEC §9.1)."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DraftPayload(BaseModel):
|
|
|
|
|
to: list[str] = []
|
|
|
|
|
cc: list[str] = []
|
|
|
|
|
bcc: list[str] = []
|
|
|
|
|
subject: str = ""
|
|
|
|
|
html: str = ""
|
|
|
|
|
text: str = ""
|
|
|
|
|
attachment_ids: list[uuid.UUID] = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DraftIn(BaseModel):
|
|
|
|
|
account_id: uuid.UUID
|
|
|
|
|
thread_id: uuid.UUID | None = None
|
|
|
|
|
reply_to_message_id: uuid.UUID | None = None
|
|
|
|
|
kind: str = "new" # reply | reply_all | forward | new
|
|
|
|
|
payload: DraftPayload
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DraftOut(BaseModel):
|
|
|
|
|
id: uuid.UUID
|
|
|
|
|
account_id: uuid.UUID
|
|
|
|
|
thread_id: uuid.UUID | None
|
|
|
|
|
reply_to_message_id: uuid.UUID | None
|
|
|
|
|
kind: str
|
|
|
|
|
payload: dict[str, object]
|
|
|
|
|
updated_at: str
|
|
|
|
|
|
|
|
|
|
|
2026-07-18 15:27:09 +02:00
|
|
|
class RemoteDraftOut(BaseModel):
|
|
|
|
|
"""A draft found in the account's IMAP Drafts folder (created on another client)."""
|
|
|
|
|
|
|
|
|
|
message_id: uuid.UUID
|
|
|
|
|
account_id: uuid.UUID
|
|
|
|
|
imap_uid: int
|
|
|
|
|
subject: str
|
|
|
|
|
to: list[str]
|
|
|
|
|
cc: list[str]
|
|
|
|
|
bcc: list[str]
|
|
|
|
|
snippet: str
|
|
|
|
|
updated_at: str
|
|
|
|
|
|
|
|
|
|
|
2026-07-17 23:20:34 +02:00
|
|
|
class SendRequest(BaseModel):
|
|
|
|
|
draft_id: uuid.UUID
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SendResponse(BaseModel):
|
|
|
|
|
outbox_id: uuid.UUID
|
|
|
|
|
undo_until: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OutboxStateOut(BaseModel):
|
|
|
|
|
outbox_id: uuid.UUID
|
|
|
|
|
state: str
|