Files
webmail-client/backend/app/outbox/schemas.py
T
lukasandClaude Opus 5.5 e1bda37188 Offline compose: write mail offline, Scheduled folder, undo countdown fix
Compose, Reply and Forward work offline. Drafts are kept on the device
(IndexedDB, lib/scheduled.ts), with files attached offline; Send becomes
"Schedule" and puts the message in a new Scheduled folder. When the server
is reachable again, scheduled messages are sent through the normal outbox
(Undo offered for a single one) and offline drafts become server drafts —
files uploaded first, each step recorded so nothing is created or sent
twice, under a Web Lock so two tabs never send the same message. Drafts
written offline show in Drafts as "On this device". Sign-out sends what
is scheduled, then wipes the device's copy.

Also: offline failures from keyboard shortcuts show "Not available
offline"; no recipient suggestions are asked for offline; a reply no
longer quotes an error page when the original is not saved.

The undo countdown counted to the server's deadline on the browser's
clock, so a few seconds of skew showed (18 s instead of 10). /send now
also returns undo_seconds, and the composer counts down from that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 21:11:41 +02:00

67 lines
1.4 KiB
Python

"""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
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
class SendRequest(BaseModel):
draft_id: uuid.UUID
class SendResponse(BaseModel):
outbox_id: uuid.UUID
undo_until: str
# The same deadline as seconds from now: the browser counts down from this,
# since its clock may be seconds off the server's.
undo_seconds: float
class OutboxStateOut(BaseModel):
outbox_id: uuid.UUID
state: str