fix: IMAP sync - use imap_uid, add sync queue with retry, restore deleted on sync, upload sent mails
- imap_delete_mail: use stored imap_uid instead of Message-ID search, raise on failure - imap_move_mail: same imap_uid fix, raise on failure - New MailSyncQueue model + migration 0007 for pending IMAP operations - delete_mail route: queues failed IMAP delete for retry - move_mail route: queues failed IMAP move for retry - process_sync_queue: retries pending delete/move operations in auto-sync loop - Auto-sync loop: processes sync queue before pulling new mails - Restore soft-deleted mails if they still exist on IMAP server during sync - Upload sent mails to IMAP Sent folder via APPEND after SMTP send - Plugin version bumped to 1.2.0
This commit is contained in:
@@ -13,10 +13,18 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def _auto_sync_loop() -> None:
|
||||
"""Background loop: sync all active mail accounts every 5 minutes."""
|
||||
from app.plugins.builtins.mail.services import auto_sync_all_accounts
|
||||
"""Background loop: process pending sync queue, then sync all active mail accounts every 5 minutes."""
|
||||
from app.plugins.builtins.mail.services import auto_sync_all_accounts, process_sync_queue
|
||||
from app.core.db import get_session_factory
|
||||
|
||||
while True:
|
||||
try:
|
||||
factory = get_session_factory()
|
||||
async with factory() as db:
|
||||
await process_sync_queue(db)
|
||||
await db.commit()
|
||||
except Exception as exc:
|
||||
logger.warning("process_sync_queue error: %s", exc)
|
||||
try:
|
||||
await auto_sync_all_accounts()
|
||||
except Exception as exc:
|
||||
@@ -31,7 +39,7 @@ class MailPlugin(BasePlugin):
|
||||
|
||||
manifest = PluginManifest(
|
||||
name="mail",
|
||||
version="1.1.0",
|
||||
version="1.2.0",
|
||||
display_name="Mail",
|
||||
description=(
|
||||
"Email management: IMAP sync, SMTP send, threading, "
|
||||
@@ -46,7 +54,7 @@ class MailPlugin(BasePlugin):
|
||||
),
|
||||
],
|
||||
events=[],
|
||||
migrations=["0001_initial.sql", "0006_flag_type.sql"],
|
||||
migrations=["0001_initial.sql", "0006_flag_type.sql", "0007_sync_queue.sql"],
|
||||
permissions=["mail:read", "mail:send", "mail:config", "mail:share", "mail:write", "mail:delete"],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user