diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php index 1061b3bde3..df51bb70b6 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php @@ -88,30 +88,26 @@ class Update extends Action try { $this->verifyRule($rule, $log); + // Reset logs and status for the rule + $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + 'logs' => '', + 'status' => RULE_STATUS_CERTIFICATE_GENERATING, + ])); + + $certificateId = $rule->getAttribute('certificateId', ''); + // Reset logs for the associated certificate. + if (!empty($certificateId)) { + $certificate = $dbForPlatform->updateDocument('certificates', $certificateId, new Document([ + 'logs' => '', + ])); + } } catch (Exception $err) { - $date = \date('H:i:s'); - $logs = "\033[90m[{$date}] \033[97m" . $err->getMessage() . "\033[0m\n"; - $logs .= "\033[90m[{$date}] \033[97mVerify your DNS records are correct and retry.\033[0m\n"; - $logs .= "\033[90m[{$date}] \033[97mAlternatively, we'll periodically retry verification and update the status.\033[0m\n"; - $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ - 'logs' => $logs, + $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + '$updatedAt' => DateTime::now(), ])); throw $err; } - // Reset logs and status for the rule - $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ - 'logs' => '', - 'status' => RULE_STATUS_CERTIFICATE_GENERATING, - ])); - $certificateId = $rule->getAttribute('certificateId', ''); - // Reset logs for the associated certificate. - if (!empty($certificateId)) { - $certificate = $dbForPlatform->updateDocument('certificates', $certificateId, new Document([ - 'logs' => '', - ])); - } - // Issue a TLS certificate when DNS verification is successful $queueForCertificates ->setDomain(new Document([ diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 7dbc9a5c32..a2f6d36505 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -487,9 +487,9 @@ class Certificates extends Action try { $this->verifyRule($rule, $log); } catch (AppwriteException $err) { - $msg = $err->getMessage(); - $msg .= "\nVerify your DNS records are correctly configured and try again."; - $msg .= "\nAlternatively, we'll periodically retry verification and update the status."; + $msg = $err->getMessage() . "\n"; + $msg .= "Verify your DNS records are correctly configured and try again.\n"; + $msg .= "Alternatively, we'll periodically retry verification and update the status.\n"; throw new AppwriteException($err->getType(), $msg); } }