Speichere die neue Position einer verschobenen IMAP-Nachricht, damit der nächste Aufruf sie direkt öffnet.
Test Suite / pytest-backend (push) Canceled after 0s
Test Suite / smoke-dev (push) Canceled after 0s
Test Suite / frontend-build (push) Canceled after 0s
Deploy Development / deploy (push) Successful in 43s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-23 13:00:25 +02:00
1 parent cd239a3ab8
commit 7a1206b18c
4 files changed
+299 -19

No files matched your search

+39
View File
@@ -217,3 +217,42 @@ def assign_reference(conn, actor_id: UUID, element_id: UUID, connector_id: UUID)
detail = dict(ref["detail"] or {})
detail["connector_id"] = str(connector_id)
_set_binding(conn, element_id, connector_id, "bound", detail)
def remember_imap_location(
conn,
element_id: UUID,
external_id: str,
previous_mailbox: str,
previous_uid: int,
mailbox: str,
uid: int,
) -> None:
"""Store the folder and UID of a message found at a new place.
Only the previous place is replaced. The message identity, the connector
and an adopted direction stay as they were.
"""
if (
not mailbox
or any(char in mailbox for char in "\r\n\x00")
or uid < 1
or (mailbox == previous_mailbox and uid == previous_uid)
):
return
conn.execute(
"""
UPDATE external_references
SET detail = jsonb_set(
jsonb_set(detail, '{mailbox}', to_jsonb(%s::text)),
'{uid}',
to_jsonb(%s::bigint)
)
WHERE element_id = %s
AND source = 'imap'
AND external_id = %s
AND detail->>'mailbox' = %s
AND detail->>'uid' = %s
""",
(mailbox, uid, element_id, external_id, previous_mailbox, str(previous_uid)),
)