Schließe die Connector-Kapselung ab, damit Paperless, IMAP und weitere Quellen über dieselbe Anbindung laufen.
Deploy Development / deploy (push) Successful in 28s
Test Suite / pytest-backend (push) Failing after 2m18s
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-19 15:00:50 +02:00
1 parent 75a3949f7c
commit d6b70d8f92
75 files changed
+9477 -414

No files matched your search

+49 -19
View File
@@ -1,5 +1,6 @@
import { useEffect, useRef, useState } from "react";
import { documentToText, downloadMailPart, fetchFile, fetchMailPart, fetchPaperless, markDirty, textToDocument, api } from "../api.js";
import { documentToText, downloadMailPart, fetchExternal, fetchFile, fetchMailPart, markDirty, textToDocument, api } from "../api.js";
import { SourceAssignment, noteEditor, representationOf } from "../sources/registry.jsx";
import { ErrorNote } from "./widgets.jsx";
import { UnitDetail } from "./correspondence.jsx";
import { dateCaption, DateField, DirectionChoice, DirectionColumn, directionValue, directionWord, formatDate, mailFacts, MarkdownEditor, sourceLabel } from "./content.jsx";
@@ -83,6 +84,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
const [pages, setPages] = useState(0);
const [scale, setScale] = useState(1);
const [text, setText] = useState("");
const [sourceText, setSourceText] = useState("");
const [note, setNote] = useState("");
const [summary, setSummary] = useState("");
const [documentOn, setDocumentOn] = useState("");
@@ -114,15 +116,15 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
useEffect(() => {
if (!element) return undefined;
const mail = element.external?.source === "imap";
if (element.kind === "note" || mail) setPhase("ready");
else if (!element.preview?.available) setPhase("missing");
const kind = representationOf(element);
if (kind === "note" || kind === "mail") setPhase("ready");
else if (kind === "locked" || kind === "unassigned" || !element.preview?.available) setPhase("missing");
setError("");
return undefined;
}, [element?.id, element?.kind, element?.external?.source, element?.preview?.available]);
}, [element?.id, element?.kind, element?.external?.source, element?.external?.resolution, element?.file?.protection_profile, element?.preview?.available]);
useEffect(() => {
if (!element || element.kind === "note" || element.external?.source === "imap" || !element.preview?.available) return undefined;
if (!element || representationOf(element) === "note" || representationOf(element) === "mail" || representationOf(element) === "locked" || representationOf(element) === "unassigned" || !element.preview?.available) return undefined;
let alive = true;
let url = "";
setPage(1);
@@ -136,9 +138,16 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
}
setBlobUrl("");
setPhase("loading");
const load = element.external?.source === "paperless" ? fetchPaperless(element.id, context) : fetchFile(element.id, context);
const view = representationOf(element);
const load = view === "source-file" || view === "text" ? fetchExternal(element.id, context) : fetchFile(element.id, context);
load.then(async (blob) => {
if (!alive) return;
if (view === "text") {
setSourceText(await blob.text());
setMedia("text");
setPhase("ready");
return;
}
url = URL.createObjectURL(blob);
setBlobUrl(url);
if (blob.type.startsWith("image/")) {
@@ -179,10 +188,10 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
alive = false;
if (url) URL.revokeObjectURL(url);
};
}, [element?.id, element?.kind, element?.external?.source, element?.preview?.available, context?.kind, context?.id]);
}, [element?.id, element?.kind, element?.external?.source, element?.external?.resolution, element?.file?.protection_profile, element?.preview?.available, context?.kind, context?.id]);
useEffect(() => {
if (!element || element.external?.source !== "imap") return undefined;
if (!element || representationOf(element) !== "mail") return undefined;
if (shownIndex === null) {
setPhase("ready");
setPdf(null);
@@ -251,7 +260,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
}, [element?.id, element?.external?.source, shownIndex, letter, context?.kind, context?.id]);
useEffect(() => {
if (!element || element.external?.source !== "imap") return undefined;
if (!element || representationOf(element) !== "mail") return undefined;
let alive = true;
const params = new URLSearchParams();
if (context?.kind && context?.id) {
@@ -330,8 +339,9 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
async function openOriginal() {
setError("");
try {
const blob = element.external?.source === "paperless"
? await fetchPaperless(element.id, context)
const view = representationOf(element);
const blob = view === "source-file" || view === "text"
? await fetchExternal(element.id, context)
: await fetchFile(element.id, context);
const url = URL.createObjectURL(blob);
window.open(url, "_blank", "noopener");
@@ -345,14 +355,20 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
event.preventDefault();
setError("");
try {
const updated = await api(`/api/v1/notes/${element.id}`, {
method: "PATCH",
body: { expected_version: element.version, document: textToDocument(text), context },
const updated = await noteEditor.save({
api,
element,
context,
document: textToDocument(text),
});
markDirty(false);
setNotice(updated.notice || "Der gemeinsame Text ist gespeichert.");
onReload();
} catch (err) {
if (err.status === 409) {
setError("Der Stand hat sich geändert. Der eingegebene Text bleibt stehen. Bitte neu laden.");
return;
}
setError(err.message);
}
}
@@ -478,7 +494,10 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
const communication = binding.communication || {};
const shownDirection = communication.direction || null;
const isMail = element.external?.source === "imap";
const kind = representationOf(element);
const isMail = kind === "mail";
const locked = kind === "locked";
const unassigned = kind === "unassigned";
const mailDetail = letter || element.external?.detail || {};
const shownFile = isMail ? (letter?.attachments || []).find((item) => item.index === shownIndex) || null : null;
@@ -564,7 +583,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
)}
</article>
) : null}
{element.kind === "note" ? (
{element.kind === "note" && noteEditor.available ? (
<form className="reader-note" onSubmit={saveNote}>
<MarkdownEditor value={text} disabled={!binding.rights.edit} onChange={(value) => { setText(value); markDirty(true); }} />
<p className="muted">Diese Änderung betrifft den gemeinsamen Inhalt der Notiz, nicht die hiesige Anmerkung. Gespeichert wird Markdown.</p>
@@ -580,8 +599,18 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
/>
<p className="muted">Keine Angabe bleibt leer. Versand- und Zugangsdatum ändern die Richtung nicht.</p>
</form>
{!isMail && phase === "loading" ? <p className="reader-pane__state">Vorschau wird geladen …</p> : null}
{!isMail && phase === "missing" ? (
{!isMail && locked ? (
<div className="reader-pane__state">
<p>Die Metadaten sind sichtbar. Der Inhalt ist geschützt und wird in dieser Lieferung nicht entschlüsselt.</p>
</div>
) : null}
{!isMail && unassigned ? (
<div className="reader-pane__state">
<SourceAssignment element={element} onAssigned={onReload} />
</div>
) : null}
{!isMail && !locked && !unassigned && phase === "loading" ? <p className="reader-pane__state">Vorschau wird geladen …</p> : null}
{!isMail && !locked && !unassigned && phase === "missing" ? (
<div className="reader-pane__state">
<p>Für diesen Inhalt gibt es keine eingebaute Vorschau.</p>
<button type="button" onClick={openOriginal}>Original öffnen</button>
@@ -593,6 +622,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
<button type="button" onClick={openOriginal}>Original öffnen</button>
</div>
) : null}
{!isMail && media === "text" ? <pre className="mail-letter__body">{sourceText}</pre> : null}
{!isMail && media === "image" && blobUrl ? (
<img className="reader-image" alt={element.title} src={blobUrl} style={{ width: `${Math.round(scale * 100)}%` }} />
) : null}