fix frontend
This commit is contained in:
@@ -33,7 +33,7 @@ from app.services.audit_service import get_real_ip
|
||||
from app.services.search_service import SearchService
|
||||
|
||||
from app.config import get_settings
|
||||
from app.core.exceptions import ForbiddenError, NotFoundError
|
||||
from app.core.exceptions import ConflictError, ForbiddenError, NotFoundError
|
||||
from app.database import get_db
|
||||
from app.dependencies import CurrentUser, DB
|
||||
from app.models.label import Label
|
||||
@@ -446,11 +446,15 @@ async def bulk_update_messages(
|
||||
elif not data.is_trashed:
|
||||
message.trashed_at = None
|
||||
if data.is_pending_conservation is not None:
|
||||
message.is_pending_conservation = data.is_pending_conservation
|
||||
if data.is_pending_conservation and not message.pending_conservation_at:
|
||||
message.pending_conservation_at = now
|
||||
elif not data.is_pending_conservation:
|
||||
message.pending_conservation_at = None
|
||||
# Guard bulk: non rimandare in conservazione messaggi gia' conservati
|
||||
if data.is_pending_conservation and message.is_conserved:
|
||||
pass # skip — gia' conservato, non viene ri-accodato
|
||||
else:
|
||||
message.is_pending_conservation = data.is_pending_conservation
|
||||
if data.is_pending_conservation and not message.pending_conservation_at:
|
||||
message.pending_conservation_at = now
|
||||
elif not data.is_pending_conservation:
|
||||
message.pending_conservation_at = None
|
||||
if data.is_conserved is not None:
|
||||
message.is_conserved = data.is_conserved
|
||||
if data.is_conserved and not message.conserved_at:
|
||||
@@ -551,6 +555,12 @@ async def update_message(
|
||||
perm_svc = PermissionService(db)
|
||||
await perm_svc.require_can_conserve(current_user, message.mailbox_id)
|
||||
|
||||
# Guard: blocca re-accodamento di messaggi gia' conservati
|
||||
if data.is_pending_conservation is True and message.is_conserved:
|
||||
raise ConflictError(
|
||||
"Questo messaggio e' gia' stato conservato e non puo' essere rimandato in conservazione."
|
||||
)
|
||||
|
||||
now = datetime.now(timezone.utc)
|
||||
ip = get_real_ip(request)
|
||||
ua = request.headers.get("user-agent")
|
||||
|
||||
@@ -69,6 +69,8 @@ class MailboxService:
|
||||
email_address=str(data.email_address),
|
||||
display_name=data.display_name,
|
||||
provider=data.provider,
|
||||
protocol_type=data.protocol_type,
|
||||
rem_provider=data.rem_provider,
|
||||
# Cifra tutte le credenziali IMAP
|
||||
imap_host_enc=encrypt_credential(data.imap_host),
|
||||
imap_port_enc=encrypt_credential(str(data.imap_port)),
|
||||
@@ -149,6 +151,10 @@ class MailboxService:
|
||||
mailbox.provider = data.provider
|
||||
if data.status is not None:
|
||||
mailbox.status = data.status
|
||||
if data.protocol_type is not None:
|
||||
mailbox.protocol_type = data.protocol_type
|
||||
if data.rem_provider is not None:
|
||||
mailbox.rem_provider = data.rem_provider
|
||||
|
||||
# IMAP
|
||||
if data.imap_host is not None:
|
||||
@@ -382,6 +388,8 @@ class MailboxService:
|
||||
"last_sync_uid": mailbox.last_sync_uid,
|
||||
"sync_error_msg": mailbox.sync_error_msg,
|
||||
"sync_error_count": mailbox.sync_error_count,
|
||||
"protocol_type": mailbox.protocol_type,
|
||||
"rem_provider": mailbox.rem_provider,
|
||||
"created_by": mailbox.created_by,
|
||||
"created_at": mailbox.created_at,
|
||||
"updated_at": mailbox.updated_at,
|
||||
|
||||
Reference in New Issue
Block a user