This commit is contained in:
2026-03-20 09:42:37 +01:00
parent e594defc00
commit 2f2f7c74c5
2 changed files with 17 additions and 7 deletions
+3 -2
View File
@@ -263,7 +263,8 @@ class IMAPConnection:
server_push = [] server_push = []
# Termina IDLE # Termina IDLE
await client.idle_done() # Nota: in aioimaplib >= 2.0.0 idle_done() e' sincrona (non coroutine)
client.idle_done()
# Controlla se ci sono nuovi messaggi (EXISTS) # Controlla se ci sono nuovi messaggi (EXISTS)
has_new = any( has_new = any(
@@ -300,7 +301,7 @@ class IMAPConnection:
except asyncio.CancelledError: except asyncio.CancelledError:
try: try:
await client.idle_done() client.idle_done()
except Exception: except Exception:
pass pass
return return
+14 -5
View File
@@ -44,14 +44,18 @@ logger = logging.getLogger(__name__)
settings = get_settings() settings = get_settings()
# Nomi comuni della cartella Sent nei provider PEC italiani (in ordine di priorità) # Nomi comuni della cartella Sent nei provider PEC italiani (in ordine di priorità)
# Aruba PEC usa INBOX.Inviata (\Sent), altri provider usano varianti diverse
SENT_FOLDER_CANDIDATES = [ SENT_FOLDER_CANDIDATES = [
"INBOX.Inviata", # Aruba PEC (verificato via LIST)
"INBOX.Sent", # Variante comune
"INBOX.Inviati", # Variante italiana
"INBOX.Sent Items",
"Sent", "Sent",
"Sent Items", "Sent Items",
"Sent Messages", "Sent Messages",
"Inviati", "Inviati",
"INBOX.Sent", "Posta inviata",
"INBOX.Inviati", "INBOX.Posta inviata",
"INBOX.Sent Items",
] ]
@@ -200,8 +204,8 @@ async def sync_new_messages(
return 0 return 0
seq_numbers = seq_numbers[: settings.imap_max_fetch_per_cycle] seq_numbers = seq_numbers[: settings.imap_max_fetch_per_cycle]
logger.info( logger.debug(
f"[{mailbox.email_address}] Trovati {len(seq_numbers)} messaggi nuovi in INBOX" f"[{mailbox.email_address}] Candidati INBOX da verificare: {len(seq_numbers)} seq"
) )
synced_count = 0 synced_count = 0
@@ -229,6 +233,11 @@ async def sync_new_messages(
exc_info=True, exc_info=True,
) )
if synced_count > 0:
logger.info(
f"[{mailbox.email_address}] Trovati {synced_count} messaggi nuovi in INBOX"
)
# Aggiorna last_sync_uid e last_sync_at # Aggiorna last_sync_uid e last_sync_at
if max_uid_synced > last_uid: if max_uid_synced > last_uid:
mailbox.last_sync_uid = max_uid_synced mailbox.last_sync_uid = max_uid_synced