From 62e459c581c877e12a84e0b3c5e186b614cc7274 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 24 Jan 2024 12:29:36 +0100 Subject: [PATCH] fix: workers --- app/controllers/api/account.php | 1 - app/worker.php | 1 + src/Appwrite/Platform/Workers/Builds.php | 2 +- src/Appwrite/Platform/Workers/Certificates.php | 6 +++++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 4ca41c010..70aef4fdc 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1107,7 +1107,6 @@ App::post('/v1/account/tokens/magic-url') $message = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-magic-url.tpl'); $message - ->setParam('{{body}}', $body, escapeHtml: false) ->setParam('{{hello}}', $locale->getText("emails.magicSession.hello")) ->setParam('{{optionButton}}', $locale->getText("emails.magicSession.optionButton")) ->setParam('{{buttonText}}', $locale->getText("emails.magicSession.buttonText")) diff --git a/app/worker.php b/app/worker.php index 5bb916285..a1454a63f 100644 --- a/app/worker.php +++ b/app/worker.php @@ -11,6 +11,7 @@ use Appwrite\Event\Delete; use Appwrite\Event\Func; use Appwrite\Event\Hamster; use Appwrite\Event\Mail; +use Appwrite\Event\Messaging; use Appwrite\Event\Migration; use Appwrite\Event\Phone; use Appwrite\Event\Usage; diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index c1e6e987c..d9ab2ad81 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -539,13 +539,13 @@ class Builds extends Action /** Trigger usage queue */ $queueForUsage - ->setProject($project) ->addMetric(METRIC_BUILDS, 1) // per project ->addMetric(METRIC_BUILDS_STORAGE, $build->getAttribute('size', 0)) ->addMetric(METRIC_BUILDS_COMPUTE, (int)$build->getAttribute('duration', 0) * 1000) ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS), 1) // per function ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_STORAGE), $build->getAttribute('size', 0)) ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_COMPUTE), (int)$build->getAttribute('duration', 0) * 1000) + ->setProject($project) ->trigger(); } } diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 7bf2b3cb1..b91f886a2 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -22,6 +22,7 @@ use Utopia\Database\Exception\Structure; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Domains\Domain; +use Utopia\Locale\Locale; use Utopia\Logger\Log; use Utopia\Platform\Action; use Utopia\Queue\Message; @@ -423,6 +424,8 @@ class Certificates extends Action // Log error into console Console::warning('Cannot renew domain (' . $domain . ') on attempt no. ' . $attempt . ' certificate: ' . $errorMessage); + $locale = new Locale(App::getEnv('_APP_LOCALE', 'en')); + // Send mail to administratore mail $template = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-certificate-failed.tpl'); $template->setParam('{{domain}}', $domain); @@ -455,8 +458,9 @@ class Certificates extends Action $queueForMails ->setSubject($subject) - ->setBody($body->render()) + ->setBody($body) ->setName('Appwrite Administrator') + ->setVariables($emailVariables) ->setRecipient(App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS')) ->trigger(); }