Lade Bilder aus E-Mails auf Wunsch über den Server nach und verkleinere den Kopf der Leseansicht auf dem Handy.
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 5m32s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 21s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
StommerandClaude Sonnet 5.5 committed 2026-10-22 16:47:24 +02:00
1 parent 075525ee17
commit a3f328832e
11 files changed
+365 -11

No files matched your search

+22 -1
View File
@@ -13,7 +13,8 @@ from app.api.deps import Principal, get_conn, get_principal
from app.api.routes import _created, _ctx_model
from app.api.schemas import ConnectorIn, ExternalIn, SourceAssignmentIn
from app.core.errors import DOWNLOAD_REFUSED, forbidden, not_found, unprocessable, unsupported
from app.mailpack import parse_mail
from app.mailpack import _inline_images, parse_mail, sanitize_html
from app.remoteimages import RemoteImages
from app.media.storage import content_disposition
from app.ops import create_external
from app.retrieval import RetrievalFailure
@@ -133,6 +134,7 @@ def view_mail(
"message_cc": parsed.copy,
"text": parsed.text,
"html": parsed.html,
"remote_images": len(parsed.remote_images),
"text_truncated": parsed.text_truncated,
"complete": not parsed.missing,
"notices": parsed.notices,
@@ -190,6 +192,25 @@ def _complete_mail(conn, principal: Principal, element, context, ref):
return parsed, raw
@router.get("/api/v1/external-refs/{element_id}/mail/html-with-images")
def view_mail_with_images(
element_id: UUID,
context_kind: str | None = None,
context_id: str | None = None,
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
"""The formatted mail with its pictures from other servers, loaded by the server on request."""
element, context, ref = _opened_ref(conn, principal, element_id, context_kind, context_id)
parsed, _raw = _complete_mail(conn, principal, element, context, ref)
loader = RemoteImages()
rendered = sanitize_html(parsed.html_source, _inline_images(parsed.attachments), remote=loader) if parsed.html_source else ""
return JSONResponse(
content={"html": rendered, "loaded": loader.loaded, "failed": loader.failed},
headers={"Cache-Control": "private, no-store", "Referrer-Policy": "no-referrer"},
)
@router.get("/api/v1/external-refs/{element_id}/mail/original")
def download_mail(
element_id: UUID,