From 17a3b3a736b279104b5ba898e7f5d5a404bd6c97 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 17 Oct 2026 18:43:51 +0200 Subject: [PATCH] Speichere die Postfachkennung als Text, damit eine uebernommene E-Mail in der Akte ankommt. Co-authored-by: Cursor --- backend/app/api/routes.py | 2 +- backend/app/api/sources.py | 2 +- backend/tests/test_direction.py | 4 ++++ frontend/src/pages/Sources.jsx | 8 +++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/app/api/routes.py b/backend/app/api/routes.py index 9814ae7..d2bbf49 100644 --- a/backend/app/api/routes.py +++ b/backend/app/api/routes.py @@ -979,7 +979,7 @@ def post_external(body: ExternalIn, principal: Principal = Depends(get_principal body.dates.document_on, body.dates.sent_on, body.dates.received_on, - body.detail.model_dump(exclude_none=True) if body.detail else None, + body.detail.model_dump(mode="json", exclude_none=True) if body.detail else None, ) return _created(f"/api/v1/elements/{element['id']}", {"id": str(element["id"]), "title": element["title"]}) diff --git a/backend/app/api/sources.py b/backend/app/api/sources.py index b887008..e235d6d 100644 --- a/backend/app/api/sources.py +++ b/backend/app/api/sources.py @@ -172,7 +172,7 @@ def link_source(body: ExternalIn, principal: Principal = Depends(get_principal), body.dates.document_on, body.dates.sent_on, body.dates.received_on, - body.detail.model_dump(exclude_none=True) if body.detail else None, + body.detail.model_dump(mode="json", exclude_none=True) if body.detail else None, ) return _created(f"/api/v1/elements/{element['id']}", {"id": str(element["id"]), "title": element["title"]}) diff --git a/backend/tests/test_direction.py b/backend/tests/test_direction.py index 5a6c25d..f88818f 100644 --- a/backend/tests/test_direction.py +++ b/backend/tests/test_direction.py @@ -61,6 +61,8 @@ def test_dates_do_not_invent_a_direction_and_explicit_choice_survives(client, db "direction": "in", "message_from": "Hausverwaltung Mueller", "mailbox": "INBOX", + "connector_id": "6f0b6a2e-1c4d-4b8a-9e2f-0a1b2c3d4e5f", + "uid": 17, }, }, status=201, @@ -76,6 +78,8 @@ def test_dates_do_not_invent_a_direction_and_explicit_choice_survives(client, db assert _binding(shown, "Scan ohne Richtung")["communication"]["direction"] is None mail = _binding(shown, "Mail der Verwaltung") assert mail["communication"] == {"direction": "in", "explicit": True} + assert mail["element"]["external"]["detail"]["connector_id"] == "6f0b6a2e-1c4d-4b8a-9e2f-0a1b2c3d4e5f" + assert mail["element"]["external"]["detail"]["uid"] == 17 ada.request( "PATCH", diff --git a/frontend/src/pages/Sources.jsx b/frontend/src/pages/Sources.jsx index 9f437b5..7676299 100644 --- a/frontend/src/pages/Sources.jsx +++ b/frontend/src/pages/Sources.jsx @@ -305,6 +305,7 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle = const [selectedKey, setSelectedKey] = useState(""); const [preview, setPreview] = useState(null); const [previewError, setPreviewError] = useState(""); + const [adopting, setAdopting] = useState(false); const [loading, setLoading] = useState(""); const [error, setError] = useState(""); @@ -433,7 +434,9 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle = } async function link(item) { + if (adopting) return; setError(""); + setAdopting(true); const letter = preview && preview.uid === item.uid ? preview : null; const known = letter?.direction || item.direction; const direction = known === "out" || known === "in" ? known : null; @@ -479,6 +482,8 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle = onDone(); } catch (err) { setError(err.message); + } finally { + setAdopting(false); } } @@ -547,7 +552,8 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle = {preview?.text ?
{preview.text}
: null} {preview?.text_truncated ?

Der Text ist gekürzt, weil die Nachricht sehr groß ist.

: null} {preview && !preview.text ?

Diese Nachricht hat keinen lesbaren Text.

: null} - + + )}