Gmail sync (SPEC: Gmail sync): - Provider fetches X-GM-LABELS when X-GM-EXT-1 is advertised; parses custom labels (system labels dropped, mUTF-7 decoded) onto RemoteMessage. - Engine syncs only system folders + All Mail for Gmail, skips every label folder, and dedupes the All Mail pass by Message-ID — kills the INBOX/All-Mail duplication. - Custom labels ride the message.new event; the labels plugin subscribes and maps them to chips as "<name> [Gmail]" (per-message + thread aggregate + known set), so labels fill in gradually with the sync window. Non-ASCII labels decode right. Labels self-healing (message-driven reconcile): - Per-message keys are the source of truth; t: aggregates and _labels are derived. Reconcile drops labels of deleted messages, regroups survivors by their current thread (fixing JWZ thread merges), rewrites changed t: keys, and rebuilds _labels from live messages — keeping user labels, dropping orphaned Gmail ones. - New SDK reads: sdk.threads.existing / sdk.messages.threads_of. Sidebar refreshes live via a plugin.labels.changed WS event on new labels. Account deletion: prune threads left empty after the cascade (they were user-scoped, so only messages cascaded) + de-list the account from surviving cross-account threads. Sync SPAM: opt-in per-account sync_spam (migration 0015, default off) — the engine skips the Junk folder in backfill and poll unless enabled; wizard checkbox added. Robustness / UX: - WebSocket auto-reconnects with backoff and resyncs on (re)connect, and account add/delete invalidates threads/labels — no more hard refresh for live updates. - Backfill banner + sidebar ring also require done < total, so a completed account can't leave a stuck "X of X". - Scrub lone UTF-16 surrogates from parsed headers/bodies so bad messages no longer crash the backfill on Postgres text/JSONB. - Ultimo signet logo in the Mail/Calendar/Contacts sidebar header (and at the top of the collapsed rail), via the shared plugin-ui.css + MailLayout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U72FZiF1W1pb8XxyWBTREA
105 lines
2.4 KiB
Python
105 lines
2.4 KiB
Python
"""Request/response models for the accounts API (SPEC §9.1)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
# How much history to import at account setup (SPEC §12 M2).
|
|
SyncWindow = Literal["all", "3months", "new"]
|
|
|
|
|
|
class ServerConfigIn(BaseModel):
|
|
host: str
|
|
port: int = Field(ge=1, le=65535)
|
|
tls: str = "ssl" # ssl | starttls
|
|
auth: str = "password" # password | oauth2
|
|
|
|
|
|
class DiscoverRequest(BaseModel):
|
|
email: str
|
|
|
|
|
|
class HelpBlockOut(BaseModel):
|
|
help_id: str
|
|
deep_link: str
|
|
app_name_hint: str = ""
|
|
steps: list[str] = []
|
|
docs_url: str = ""
|
|
setup_link: str = ""
|
|
button_after_step: int = 0
|
|
|
|
|
|
class CandidateOut(BaseModel):
|
|
imap: ServerConfigIn
|
|
smtp: ServerConfigIn
|
|
source: str
|
|
oauth_provider: str | None = None
|
|
auth_strategy: list[str] = ["password"]
|
|
help: HelpBlockOut | None = None
|
|
|
|
|
|
class DiscoveryStepOut(BaseModel):
|
|
method: str
|
|
status: str
|
|
detail: str = ""
|
|
|
|
|
|
class DiscoverResponse(BaseModel):
|
|
candidates: list[CandidateOut]
|
|
steps: list[DiscoveryStepOut]
|
|
# Whether the wizard may offer the Google OAuth fallback (SPEC §6.2.1).
|
|
google_oauth_enabled: bool = False
|
|
|
|
|
|
class TestRequest(BaseModel):
|
|
imap: ServerConfigIn
|
|
smtp: ServerConfigIn
|
|
email: str
|
|
username: str | None = None # defaults to the email address
|
|
password: str = Field(min_length=1)
|
|
|
|
|
|
class TestResponse(BaseModel):
|
|
ok: bool = True
|
|
|
|
|
|
class CreateAccountRequest(BaseModel):
|
|
email: str
|
|
display_name: str = ""
|
|
color: str = "#888888"
|
|
imap: ServerConfigIn
|
|
smtp: ServerConfigIn
|
|
username: str | None = None
|
|
password: str = Field(min_length=1)
|
|
sync_window: SyncWindow = "all"
|
|
sync_spam: bool = False
|
|
|
|
|
|
class UpdateAccountRequest(BaseModel):
|
|
display_name: str | None = None
|
|
color: str | None = None
|
|
signature: str | None = None
|
|
sync_window: SyncWindow | None = None
|
|
# Connection/credential changes require the password (re-validated + re-encrypted).
|
|
imap: ServerConfigIn | None = None
|
|
smtp: ServerConfigIn | None = None
|
|
password: str | None = None
|
|
|
|
|
|
class AccountDetailOut(BaseModel):
|
|
id: uuid.UUID
|
|
email: str
|
|
display_name: str
|
|
color: str
|
|
state: str
|
|
state_detail: str
|
|
signature: str
|
|
sync_window: str
|
|
backfill_total: int
|
|
backfill_done: int
|
|
imap_config: dict[str, object]
|
|
smtp_config: dict[str, object]
|