feat: mail phase 4 - IMAP folder create/delete + auto-sync
- Add imap_create_folder() and imap_delete_folder() service functions - Call IMAP CREATE/DELETE in folder create/delete endpoints - Add auto_sync_all_accounts() background task (every 5 min) - Start auto-sync loop on plugin activation via asyncio.create_task - Frontend: working sync button with isSyncing state and toast feedback - i18n: syncSuccess, syncFailed, syncing, autoSyncEnabled keys (de/en)
This commit is contained in:
@@ -73,6 +73,8 @@ from app.plugins.builtins.mail.services import (
|
||||
folder_to_response,
|
||||
forward_mail,
|
||||
get_account_password,
|
||||
imap_create_folder,
|
||||
imap_delete_folder,
|
||||
imap_delete_mail,
|
||||
imap_move_mail,
|
||||
imap_sync_account,
|
||||
@@ -514,6 +516,14 @@ async def create_folder(
|
||||
)
|
||||
db.add(folder)
|
||||
await db.flush()
|
||||
try:
|
||||
await imap_create_folder(db, acc_id, data.imap_name, tenant_id)
|
||||
except Exception:
|
||||
import logging as _logging
|
||||
|
||||
_logging.getLogger(__name__).warning(
|
||||
"create_folder: IMAP CREATE failed (non-critical) for %s", data.imap_name
|
||||
)
|
||||
return folder_to_response(folder)
|
||||
|
||||
|
||||
@@ -559,6 +569,14 @@ async def delete_folder(
|
||||
raise HTTPException(404, detail={"detail": "Folder not found", "code": "not_found"})
|
||||
account = await _get_account(db, folder.account_id, tenant_id, user_id)
|
||||
await _check_delegate_full_access(db, account, user_id)
|
||||
try:
|
||||
await imap_delete_folder(db, f_id, tenant_id)
|
||||
except Exception:
|
||||
import logging as _logging
|
||||
|
||||
_logging.getLogger(__name__).warning(
|
||||
"delete_folder: IMAP DELETE failed (non-critical) for folder %s", f_id
|
||||
)
|
||||
await db.delete(folder)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user