diff --git a/app/config/locale/templates/email-webhook.tpl b/app/config/locale/templates/email-webhook.tpl new file mode 100644 index 000000000..be877e357 --- /dev/null +++ b/app/config/locale/templates/email-webhook.tpl @@ -0,0 +1,234 @@ + + + + + + + + +
+ + + + +
+ +
+ + + + + +
+

{{subject}}

+
+ + + + + +
{{message}}
+ + + + + +
+ + + + + + + +
+ + + + + +
+ + + + + + +
Terms +
|
+
Privacy
+

+ © 2023 Appwrite | 251 Little Falls Drive, Wilmington 19808, + Delaware, United States +

+
+ + \ No newline at end of file diff --git a/app/config/locale/translations/en.json b/app/config/locale/translations/en.json index 59df64aba..3ff6665b2 100644 --- a/app/config/locale/translations/en.json +++ b/app/config/locale/translations/en.json @@ -33,12 +33,8 @@ "emails.certificate.footer": "Your previous certificate will be valid for 30 days since the first failure. We highly recommend investigating this case, otherwise your domain will end up without a valid SSL communication.", "emails.certificate.thanks": "Thanks", "emails.certificate.signature": "{{project}} team", - "emails.webhook.subject": "Your webhook {{webhook}} has been stopped", - "emails.webhook.hello": "Hello {{user}}", - "emails.webhook.body": "Your webhook {{webhook}} on project {{project}} has been stopped after {{attempts}} consecutive failures.


Webhook endpoint: {{url}}


To restore the functionality of your webhook, please take the following steps:
1. Debug the webhook to identify and resolve the issue.
2. Re-enable the webhook from the project settings page.", - "emails.webhook.footer": "If you need any assistance, please reach out to our team on Discord.", - "emails.webhook.thanks": "Thanks", - "emails.webhook.signature": "{{project}} team", + "emails.webhook.subject": "Your webhook has been stopped", + "emails.webhook.body": "Hello {{user}},

Your webhook {{webhook}} on project {{project}} has been stopped after {{attempts}} consecutive failures.

Webhook URL: {{url}}
Error: {{error}}

For more details, view logs of your webhook in Appwrite Console.

To restore the functionality of your webhook, please take the following steps:
1. Debug the webhook to identify and resolve the issue.
2. Re-enable the webhook from the project settings page.

If you need any assistance, please reach out to our team on Discord or using email support.", "locale.country.unknown": "Unknown", "countries.af": "Afghanistan", "countries.ao": "Angola", diff --git a/docker-compose.yml b/docker-compose.yml index e127773f4..8a9b745a9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -299,6 +299,8 @@ services: - _APP_REDIS_PASS - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG + - _APP_DOMAIN + - _APP_OPTIONS_FORCE_HTTPS appwrite-worker-deletes: entrypoint: worker-deletes diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index 28bcc1688..902502524 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -163,22 +163,26 @@ class Webhooks extends Action $subject = $locale->getText("emails.webhook.subject"); - $message = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-inner-base.tpl'); + $message = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-webhook.tpl'); $message - ->setParam('{{hello}}', $locale->getText("emails.webhook.hello")) - ->setParam('{{body}}', $locale->getText("emails.webhook.body")) - ->setParam('{{footer}}', $locale->getText("emails.webhook.footer")) - ->setParam('{{thanks}}', $locale->getText("emails.webhook.thanks")) - ->setParam('{{signature}}', $locale->getText("emails.webhook.signature")); + ->setParam('{{subject}}', $subject) + ->setParam('{{message}}', $locale->getText("emails.webhook.body")); $body = $message->render(); + $protocol = App::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; + $hostname = App::getEnv('_APP_DOMAIN'); + $projectId = $project->getId(); + $webhookId = $webhook->getId(); + $emailVariables = [ + 'subject' => $subject, 'user' => $user->getAttribute('name'), 'project' => $project->getAttribute('name'), - 'redirect' => '', + 'link' => $protocol . '://' . $hostname . "/console/project-$projectId/settings/webhooks/$webhookId", 'webhook' => $webhook->getAttribute('name'), 'attempts' => $attempts, 'url' => $webhook->getAttribute('url'), + 'error' => $curlError ?? \mb_strcut($responseBody, 0, 10000), ]; $queueForMails