fix: gate provisioning on mailu mailbox
This commit is contained in:
parent
1dabd78921
commit
ce66744a9e
@ -307,6 +307,7 @@ class ProvisioningManager:
|
|||||||
|
|
||||||
# Task: trigger Mailu sync
|
# Task: trigger Mailu sync
|
||||||
start = datetime.now(timezone.utc)
|
start = datetime.now(timezone.utc)
|
||||||
|
mailbox_ready = True
|
||||||
try:
|
try:
|
||||||
if not settings.mailu_sync_url:
|
if not settings.mailu_sync_url:
|
||||||
detail = "sync disabled"
|
detail = "sync disabled"
|
||||||
@ -314,13 +315,22 @@ class ProvisioningManager:
|
|||||||
self._record_task(request_code, "mailu_sync", "ok", detail, start)
|
self._record_task(request_code, "mailu_sync", "ok", detail, start)
|
||||||
else:
|
else:
|
||||||
mailu.sync(reason="ariadne_access_approve", force=True)
|
mailu.sync(reason="ariadne_access_approve", force=True)
|
||||||
|
mailbox_ready = mailu.wait_for_mailbox(
|
||||||
|
mailu_email, settings.mailu_mailbox_wait_timeout_sec
|
||||||
|
)
|
||||||
|
if not mailbox_ready:
|
||||||
|
raise RuntimeError("mailbox not ready")
|
||||||
self._upsert_task(conn, request_code, "mailu_sync", "ok", None)
|
self._upsert_task(conn, request_code, "mailu_sync", "ok", None)
|
||||||
self._record_task(request_code, "mailu_sync", "ok", None, start)
|
self._record_task(request_code, "mailu_sync", "ok", None, start)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
mailbox_ready = False
|
||||||
detail = safe_error_detail(exc, "failed to sync mailu")
|
detail = safe_error_detail(exc, "failed to sync mailu")
|
||||||
self._upsert_task(conn, request_code, "mailu_sync", "error", detail)
|
self._upsert_task(conn, request_code, "mailu_sync", "error", detail)
|
||||||
self._record_task(request_code, "mailu_sync", "error", detail, start)
|
self._record_task(request_code, "mailu_sync", "error", detail, start)
|
||||||
|
|
||||||
|
if not mailbox_ready:
|
||||||
|
return ProvisionOutcome(ok=False, status="accounts_building")
|
||||||
|
|
||||||
# Task: trigger Nextcloud mail sync
|
# Task: trigger Nextcloud mail sync
|
||||||
start = datetime.now(timezone.utc)
|
start = datetime.now(timezone.utc)
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user