Files
lukasandClaude Opus 4.8 3951df9755 Two-way draft sync, signatures, sent/bcc fixes, and mail-list UI
Backend
- Sent copies: persist locally on send + periodic multi-folder CONDSTORE poll
  (Sent/Archive/Trash/Junk) so they thread and show without an IDLE-only INBOX.
- Bcc: transmitted copy omits Bcc, Sent copy keeps it; store/display bcc_addr.
- Drafts: mirror local drafts to the IMAP Drafts folder (append/replace/expunge);
  inbound sync of foreign drafts (un-threaded) with adopt-to-edit + dedup by UID.
- Per-user storage quota (5 GiB default) and manual "sync all folders" action.
- Account editing (display/color/server/password) and per-account HTML signature.
- Account view scoped to that account's inbox; new migrations 0006–0009.

Frontend
- Mail-list pagination, folder filters (All/Unread/Pinned), sort toggle, refresh.
- Aligned + widened mail-list margins; reading-pane bars fixed height.
- Rich-text composer: color palette, highlight, image; attachments; expand/pop-out.
- Signatures: auto-insert for new mail, replace on From change, reply insert.
- Restore/Delete actions per folder; drafts view merges local + remote, date-sorted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 15:27:09 +02:00

41 lines
1.2 KiB
Python

"""Resolve a draft's compose-attachment ids into raw (filename, mime, data) tuples."""
from __future__ import annotations
import uuid
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.indexer import blobstore
from app.models import ComposeAttachment, Draft
async def load_attachments(
session: AsyncSession, user_id: uuid.UUID, draft: Draft
) -> list[tuple[str, str, bytes]]:
"""Return each of the draft's compose attachments as ``(filename, mime, data)``."""
raw_ids = draft.payload.get("attachment_ids") or []
if not isinstance(raw_ids, list) or not raw_ids:
return []
ids: list[uuid.UUID] = []
for value in raw_ids:
try:
ids.append(uuid.UUID(str(value)))
except ValueError:
continue
if not ids:
return []
rows = await session.scalars(
select(ComposeAttachment).where(
ComposeAttachment.id.in_(ids), ComposeAttachment.user_id == user_id
)
)
by_id = {r.id: r for r in rows}
out: list[tuple[str, str, bytes]] = []
for i in ids:
att = by_id.get(i)
if att is not None:
out.append((att.filename, att.mime_type, blobstore.load(user_id, att.blob_sha256)))
return out