1
0
Fork 0
mirror of synced 2024-07-03 13:41:01 +12:00

Update emails from certificate worker to match pattern of other emails

Since the certificate worker is sending a job to the mails worker just
like the controllers, it should prepare the email in the same way by
localizing and then sending the inner template for the mail worker to
apply the layout and final variables.

This commit also fixes a problem with a missing subject.
This commit is contained in:
Steven Nguyen 2023-10-04 16:34:38 -07:00
parent 836ce852ed
commit fc4fa977a0
No known key found for this signature in database

View file

@ -426,26 +426,31 @@ class Certificates extends Action
$locale->setDefault('en');
}
$body = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-base.tpl');
$subject = \sprintf($locale->getText("emails.certificate.subject"), $domain);
$body
->setParam('{{domain}}', $domain)
->setParam('{{error}}', $errorMessage)
->setParam('{{attempt}}', $attempt)
->setParam('{{subject}}', $subject)
->setParam('{{hello}}', $locale->getText("emails.certificate.hello"))
$message = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-inner-base.tpl');
$message
->setParam('{{body}}', $locale->getText("emails.certificate.body"))
->setParam('{{redirect}}', 'https://' . $domain)
->setParam('{{hello}}', $locale->getText("emails.certificate.hello"))
->setParam('{{footer}}', $locale->getText("emails.certificate.footer"))
->setParam('{{thanks}}', $locale->getText("emails.certificate.thanks"))
->setParam('{{signature}}', $locale->getText("emails.certificate.signature"))
->setParam('{{project}}', 'Console')
->setParam('{{direction}}', $locale->getText('settings.direction'));
->setParam('{{signature}}', $locale->getText("emails.certificate.signature"));
$body = $message->render();
$emailVariables = [
'direction' => $locale->getText('settings.direction'),
'domain' => $domain,
'error' => '<br><pre>' . $errorMessage . '</pre>',
'attempt' => $attempt,
'project' => 'Console',
'redirect' => 'https://' . $domain,
];
$queueForMails
->setRecipient(App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS'))
->setBody($body->render())
->setSubject($subject)
->setBody($body)
->setVariables($emailVariables)
->setName('Appwrite Administrator')
->trigger();
}