1
0
Fork 0
mirror of synced 2024-06-14 16:54:52 +12:00

Add env variables to mails worker instead of webhooks worker

This commit is contained in:
Khushboo Verma 2024-01-19 17:09:48 +05:30
parent 7efdc7556d
commit 3e5443f127
5 changed files with 17 additions and 14 deletions

View file

@ -14,7 +14,7 @@
<table border="0" cellspacing="0" cellpadding="0" style="padding-top: 10px; padding-bottom: 10px; margin-top: 32px">
<tr>
<td style="border-radius: 8px; display: block; width: 100%;">
<a class="mobile-full-width" rel="noopener" target="_blank" href="{{redirect}}" style="font-size: 14px; font-family: Inter; color: #ffffff; text-decoration: none; background-color: #FD366E; border-radius: 8px; padding: 9px 14px; border: 1px solid #FD366E; display: inline-block; text-align:center; box-sizing: border-box;">Webhook settings</a>
<a class="mobile-full-width" rel="noopener" target="_blank" href="{{protocol}}://{{hostname}}{{redirect}}" style="font-size: 14px; font-family: Inter; color: #ffffff; text-decoration: none; background-color: #FD366E; border-radius: 8px; padding: 9px 14px; border: 1px solid #FD366E; display: inline-block; text-align:center; box-sizing: border-box;">Webhook settings</a>
</td>
</tr>
</table>

12
composer.lock generated
View file

@ -3140,16 +3140,16 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "0.36.0",
"version": "0.36.1",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "3a10f1f895ed71120442ff71eb6adec3fd6b4e8a"
"reference": "ca4700bfbbb8bcf1c0d5a49fc5efc38da98d0992"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/3a10f1f895ed71120442ff71eb6adec3fd6b4e8a",
"reference": "3a10f1f895ed71120442ff71eb6adec3fd6b4e8a",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/ca4700bfbbb8bcf1c0d5a49fc5efc38da98d0992",
"reference": "ca4700bfbbb8bcf1c0d5a49fc5efc38da98d0992",
"shasum": ""
},
"require": {
@ -3185,9 +3185,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/0.36.0"
"source": "https://github.com/appwrite/sdk-generator/tree/0.36.1"
},
"time": "2023-11-20T10:03:06+00:00"
"time": "2024-01-18T06:24:47+00:00"
},
{
"name": "doctrine/deprecations",

View file

@ -192,6 +192,7 @@ services:
- _APP_MESSAGE_SMS_TEST_DSN
- _APP_MESSAGE_EMAIL_TEST_DSN
- _APP_MESSAGE_PUSH_TEST_DSN
appwrite-realtime:
entrypoint: realtime
<<: *x-logging
@ -300,8 +301,6 @@ services:
- _APP_REDIS_PASS
- _APP_LOGGING_PROVIDER
- _APP_LOGGING_CONFIG
- _APP_DOMAIN
- _APP_OPTIONS_FORCE_HTTPS
appwrite-worker-deletes:
entrypoint: worker-deletes
@ -561,6 +560,8 @@ services:
- _APP_SMTP_PASSWORD
- _APP_LOGGING_PROVIDER
- _APP_LOGGING_CONFIG
- _APP_DOMAIN
- _APP_OPTIONS_FORCE_HTTPS
appwrite-worker-messaging:
entrypoint: worker-messaging

View file

@ -29,7 +29,7 @@ class Mails extends Action
->inject('message')
->inject('register')
->inject('log')
->callback(fn(Message $message, Registry $register, Log $log) => $this->action($message, $register, $log));
->callback(fn (Message $message, Registry $register, Log $log) => $this->action($message, $register, $log));
}
/**
@ -63,6 +63,11 @@ class Mails extends Action
$name = $payload['name'];
$body = $payload['body'];
$protocol = App::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https';
$hostname = App::getEnv('_APP_DOMAIN');
$body = str_replace(['{{protocol}}', '{{hostname}}'], [$protocol, $hostname], $body);
$bodyTemplate = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-base.tpl');
$bodyTemplate->setParam('{{body}}', $body);
foreach ($variables as $key => $value) {

View file

@ -4,7 +4,6 @@ namespace Appwrite\Platform\Workers;
use Appwrite\Event\Mail;
use Appwrite\Template\Template;
use Appwrite\Utopia\View;
use Exception;
use Utopia\App;
use Utopia\Database\Document;
@ -196,8 +195,6 @@ class Webhooks extends Action
Query::equal('$id', $userIds),
]);
$protocol = App::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https';
$hostname = App::getEnv('_APP_DOMAIN');
$projectId = $project->getId();
$webhookId = $webhook->getId();
@ -207,7 +204,7 @@ class Webhooks extends Action
$template->setParam('{{project}}', $project->getAttribute('name'));
$template->setParam('{{url}}', $webhook->getAttribute('url'));
$template->setParam('{{error}}', $curlError ?? 'The server returned ' . $statusCode . ' status code');
$template->setParam('{{redirect}}', $protocol . '://' . $hostname . "/console/project-$projectId/settings/webhooks/$webhookId");
$template->setParam('{{redirect}}', "/console/project-$projectId/settings/webhooks/$webhookId");
$template->setParam('{{attempts}}', $attempts);
$subject = 'Webhook deliveries have been paused';