fix parsing ricevute
This commit is contained in:
@@ -364,6 +364,32 @@ async def sync_sent_messages(
|
||||
f"[{mailbox.email_address}] Errore fetch {sent_folder!r} seq {seq}: {e}",
|
||||
exc_info=True,
|
||||
)
|
||||
|
||||
if synced_count > 0:
|
||||
logger.info(
|
||||
f"[{mailbox.email_address}] Sincronizzati {synced_count} messaggi nuovi da {sent_folder!r}"
|
||||
)
|
||||
|
||||
# Aggiorna sent_last_sync_uid e torna in INBOX
|
||||
if max_uid_synced > last_uid:
|
||||
mailbox.sent_last_sync_uid = max_uid_synced
|
||||
mailbox.last_sync_at = datetime.now(UTC)
|
||||
await db.flush()
|
||||
await db.commit()
|
||||
|
||||
try:
|
||||
await imap_client.select("INBOX")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return synced_count
|
||||
|
||||
|
||||
async def _fetch_and_save_message_by_seq(
|
||||
imap_client: aioimaplib.IMAP4 | aioimaplib.IMAP4_SSL,
|
||||
seq: str,
|
||||
last_uid: int,
|
||||
mailbox: Mailbox,
|
||||
db: AsyncSession,
|
||||
redis_client: aioredis.Redis,
|
||||
imap_folder: str = "INBOX",
|
||||
@@ -711,6 +737,10 @@ async def _save_message(
|
||||
body_html=parsed.body_html,
|
||||
has_attachments=parsed.has_attachments,
|
||||
parent_message_id=parent_message_id,
|
||||
# Salva il X-Riferimento-Message-ID per il binding retroattivo.
|
||||
# Permette allo script rebind_receipts.py di ricollegare ricevute orfane
|
||||
# senza dover ri-leggere l'EML da MinIO.
|
||||
riferimento_message_id=_riferimento_message_id if _is_receipt else None,
|
||||
raw_eml_path=eml_path,
|
||||
# Messaggi outbound (Sent) sono già stati letti dal mittente
|
||||
is_read=(direction == "outbound"),
|
||||
|
||||
Reference in New Issue
Block a user