Lade eine uebernommene E-Mail bei Bedarf vollstaendig, damit Anzeige und Export nicht an der Vorschau haengen.
Deploy Development / deploy (push) Successful in 27s
Test Suite / pytest-backend (push) Failing after 1m10s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 10s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-17 18:59:18 +02:00
1 parent 17a3b3a736
commit 7626c56f3d
7 files changed
+740 -19

No files matched your search

+59
View File
@@ -67,6 +67,35 @@ export async function api(path, { method = "GET", body, form } = {}) {
return data;
}
function mailQuery(context) {
const params = new URLSearchParams();
if (context?.kind && context?.id) {
params.set("context_kind", context.kind);
params.set("context_id", context.id);
}
return params;
}
export async function downloadMailPart(elementId, context, suffix, filename) {
const response = await fetch(`/api/v1/external-refs/${elementId}/mail/${suffix}?${mailQuery(context)}`, {
credentials: "include",
headers: scopeHeaders(),
});
if (!response.ok) {
const data = await response.json().catch(() => null);
throw new Error(data?.detail || "Die vollständige E-Mail ist nicht verfügbar.");
}
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = filename || "nachricht.eml";
document.body.appendChild(link);
link.click();
link.remove();
setTimeout(() => URL.revokeObjectURL(url), 60000);
}
export async function fetchPaperless(elementId, context) {
const params = new URLSearchParams();
if (context?.kind && context?.id) {
@@ -122,6 +151,36 @@ export async function downloadFile(elementId, context, filename) {
URL.revokeObjectURL(url);
}
export async function downloadPost(path, body, fallbackName) {
const headers = { ...scopeHeaders(), "Content-Type": "application/json" };
if (csrf) headers["X-CSRF-Token"] = csrf;
const response = await fetch(path, {
method: "POST",
headers,
body: JSON.stringify(body),
credentials: "include",
});
if (!response.ok) {
const data = await response.json().catch(() => null);
const error = new Error(data?.detail || "Die Anfrage ist fehlgeschlagen.");
error.status = response.status;
throw error;
}
const blob = await response.blob();
const disposition = response.headers.get("Content-Disposition") || "";
const extended = disposition.match(/filename\*=UTF-8''([^;]+)/i);
const plain = disposition.match(/filename="([^"]+)"/);
const filename = extended ? decodeURIComponent(extended[1]) : (plain && plain[1]) || fallbackName || "uebergabe.zip";
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
link.remove();
URL.revokeObjectURL(url);
}
export function textToDocument(text) {
return { version: 1, blocks: [{ type: "markdown", text: text || "" }] };
}