04/13/2026 Fixed email ingres function

This commit is contained in:
2026-04-13 18:18:15 -04:00
parent 7f025c613f
commit cacc92636a
4 changed files with 257 additions and 59 deletions
+13 -4
View File
@@ -436,19 +436,28 @@ def _run_ingestion(app):
f'from={from_email} subject="{subject[:60]}" '
f'attachments={attach_count}'
)
notify_new_ticket(ticket)
try:
notify_new_ticket(ticket)
except Exception as notify_exc:
logger.error(
f'[EMAIL INGEST] Notification failed for ticket '
f'{ticket.ticket_number}: {notify_exc}'
)
# Track message ID for deduplication
if message_id:
new_ids.add(message_id)
created += 1
# Move processed message to done folder
# Move processed message to done folder.
# RFC 3501: folder names with spaces or special chars must
# be double-quoted in IMAP commands.
quoted_move_to = f'"{move_to}"'
try:
imap.create(move_to)
imap.create(quoted_move_to)
except Exception:
pass # folder may already exist
imap.copy(num, move_to)
imap.copy(num, quoted_move_to)
imap.store(num, '+FLAGS', '\\Deleted')
except Exception as exc: