From 77cd6a4a04031162c832042f500e062abb0654ac Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 14 May 2025 18:04:08 +0200 Subject: [PATCH] feat(backend): add support line to emails (#8502) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(backend): add support line to emails * - fixed snapshots --------- Co-authored-by: Wolfgang Huß Co-authored-by: Sebastian Stein --- backend/.env.template | 2 +- backend/.env.test_e2e | 2 +- backend/src/config/emails.ts | 3 - backend/src/config/index.ts | 1 + .../sendChatMessageMail.spec.ts.snap | 12 + .../sendEmailVerification.spec.ts.snap | 12 + .../sendNotificationMail.spec.ts.snap | 108 ++++ .../sendRegistrationMail.spec.ts.snap | 24 + .../sendResetPasswordMail.spec.ts.snap | 12 + .../__snapshots__/sendWrongEmail.spec.ts.snap | 12 + .../__snapshots__/supportLine.spec.ts.snap | 531 ++++++++++++++++++ backend/src/emails/locales/de.json | 1 + backend/src/emails/locales/en.json | 1 + backend/src/emails/sendEmail.ts | 3 +- backend/src/emails/supportLine.spec.ts | 67 +++ .../src/emails/templates/includes/support.pug | 2 + backend/src/emails/templates/layout.pug | 5 + 17 files changed, 792 insertions(+), 6 deletions(-) create mode 100644 backend/src/emails/__snapshots__/supportLine.spec.ts.snap create mode 100644 backend/src/emails/supportLine.spec.ts create mode 100644 backend/src/emails/templates/includes/support.pug diff --git a/backend/.env.template b/backend/.env.template index eb710101e..52acdcc31 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -7,7 +7,7 @@ GRAPHQL_URI=http://localhost:4000 CLIENT_URI=http://localhost:3000 # E-Mail default settings -EMAIL_SUPPORT="devops@ocelot.social" +SUPPORT_EMAIL="devops@ocelot.social" EMAIL_DEFAULT_SENDER="devops@ocelot.social" SMTP_HOST= SMTP_PORT= diff --git a/backend/.env.test_e2e b/backend/.env.test_e2e index e21ce3057..20d1263c0 100644 --- a/backend/.env.test_e2e +++ b/backend/.env.test_e2e @@ -7,7 +7,7 @@ GRAPHQL_URI=http://localhost:4000 CLIENT_URI=http://localhost:3000 # E-Mail default settings -EMAIL_SUPPORT="devops@ocelot.social" +SUPPORT_EMAIL="devops@ocelot.social" EMAIL_DEFAULT_SENDER="devops@ocelot.social" SMTP_HOST=mailserver SMTP_PORT=1025 diff --git a/backend/src/config/emails.ts b/backend/src/config/emails.ts index 34daaecb0..8a746f085 100644 --- a/backend/src/config/emails.ts +++ b/backend/src/config/emails.ts @@ -1,8 +1,5 @@ // this file is duplicated in `backend/src/config/` and `webapp/constants/` and replaced on rebranding by https://github.com/Ocelot-Social-Community/Ocelot-Social-Deploy-Rebranding/tree/master/branding/constants/ export default { - SUPPORT_EMAIL: 'devops@ocelot.social', - MODERATION_EMAIL: 'devops@ocelot.social', - // ATTENTION: the following links have to be defined even for internal pages with full URLs as example like 'https://staging.ocelot.social/support', because they are used in e-mails! ORGANIZATION_LINK: 'https://ocelot.social', SUPPORT_LINK: 'https://ocelot.social', } diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 6dfd5a808..1aa7991eb 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -112,6 +112,7 @@ const s3 = { const options = { EMAIL_DEFAULT_SENDER: env.EMAIL_DEFAULT_SENDER, + SUPPORT_EMAIL: env.SUPPORT_EMAIL, SUPPORT_URL: emails.SUPPORT_LINK, APPLICATION_NAME: metadata.APPLICATION_NAME, ORGANIZATION_URL: emails.ORGANIZATION_LINK, diff --git a/backend/src/emails/__snapshots__/sendChatMessageMail.spec.ts.snap b/backend/src/emails/__snapshots__/sendChatMessageMail.spec.ts.snap index 67c141c0e..86e2c22ec 100644 --- a/backend/src/emails/__snapshots__/sendChatMessageMail.spec.ts.snap +++ b/backend/src/emails/__snapshots__/sendChatMessageMail.spec.ts.snap @@ -99,6 +99,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -121,6 +124,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -226,6 +232,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -248,6 +257,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", diff --git a/backend/src/emails/__snapshots__/sendEmailVerification.spec.ts.snap b/backend/src/emails/__snapshots__/sendEmailVerification.spec.ts.snap index 7f718d936..63ae9c98f 100644 --- a/backend/src/emails/__snapshots__/sendEmailVerification.spec.ts.snap +++ b/backend/src/emails/__snapshots__/sendEmailVerification.spec.ts.snap @@ -99,6 +99,9 @@ footer {

– The ocelot.social Team

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -124,6 +127,9 @@ See you soon on ocelot.social [https://ocelot.social]! – The ocelot.social Team +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -229,6 +235,9 @@ footer {

– Dein ocelot.social Team

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -254,6 +263,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! – Dein ocelot.social Team +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", diff --git a/backend/src/emails/__snapshots__/sendNotificationMail.spec.ts.snap b/backend/src/emails/__snapshots__/sendNotificationMail.spec.ts.snap index 05ec17e94..3770d9bdb 100644 --- a/backend/src/emails/__snapshots__/sendNotificationMail.spec.ts.snap +++ b/backend/src/emails/__snapshots__/sendNotificationMail.spec.ts.snap @@ -98,6 +98,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -120,6 +123,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -225,6 +231,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -248,6 +257,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -353,6 +365,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -376,6 +391,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -481,6 +499,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -504,6 +525,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -609,6 +633,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -631,6 +658,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -735,6 +765,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -757,6 +790,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -861,6 +897,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -880,6 +919,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -985,6 +1027,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -1007,6 +1052,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -1112,6 +1160,9 @@ footer {

PS: If you don't want to receive e-mails anymore, change your notification settings!

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -1134,6 +1185,9 @@ See you soon on ocelot.social [https://ocelot.social]! PS: If you don't want to receive e-mails anymore, change your notification settings [http://webapp:3000/settings/notifications]! +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -1238,6 +1292,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -1260,6 +1317,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -1365,6 +1425,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -1388,6 +1451,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -1493,6 +1559,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -1516,6 +1585,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -1621,6 +1693,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -1644,6 +1719,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -1749,6 +1827,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -1771,6 +1852,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -1875,6 +1959,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -1897,6 +1984,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -2001,6 +2091,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -2020,6 +2113,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -2125,6 +2221,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -2147,6 +2246,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -2252,6 +2354,9 @@ footer {

PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen!

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -2274,6 +2379,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! PS: Möchtest du keine E-Mails mehr erhalten, dann ändere deine Benachrichtigungseinstellungen [http://webapp:3000/settings/notifications]! +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", diff --git a/backend/src/emails/__snapshots__/sendRegistrationMail.spec.ts.snap b/backend/src/emails/__snapshots__/sendRegistrationMail.spec.ts.snap index 16f7584e5..562e3b16c 100644 --- a/backend/src/emails/__snapshots__/sendRegistrationMail.spec.ts.snap +++ b/backend/src/emails/__snapshots__/sendRegistrationMail.spec.ts.snap @@ -102,6 +102,9 @@ footer {

– The ocelot.social Team

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -133,6 +136,9 @@ See you soon on ocelot.social [https://ocelot.social]! – The ocelot.social Team +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -241,6 +247,9 @@ footer {

– Dein ocelot.social Team

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -273,6 +282,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! – Dein ocelot.social Team +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -381,6 +393,9 @@ footer {

– The ocelot.social Team

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -412,6 +427,9 @@ See you soon on ocelot.social [https://ocelot.social]! – The ocelot.social Team +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -520,6 +538,9 @@ footer {

– Dein ocelot.social Team

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -552,6 +573,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! – Dein ocelot.social Team +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", diff --git a/backend/src/emails/__snapshots__/sendResetPasswordMail.spec.ts.snap b/backend/src/emails/__snapshots__/sendResetPasswordMail.spec.ts.snap index da8c041cb..d7f10b33d 100644 --- a/backend/src/emails/__snapshots__/sendResetPasswordMail.spec.ts.snap +++ b/backend/src/emails/__snapshots__/sendResetPasswordMail.spec.ts.snap @@ -99,6 +99,9 @@ footer {

– The ocelot.social Team

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -123,6 +126,9 @@ See you soon on ocelot.social [https://ocelot.social]! – The ocelot.social Team +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -228,6 +234,9 @@ footer {

– Dein ocelot.social Team

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -253,6 +262,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! – Dein ocelot.social Team +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", diff --git a/backend/src/emails/__snapshots__/sendWrongEmail.spec.ts.snap b/backend/src/emails/__snapshots__/sendWrongEmail.spec.ts.snap index b2052d808..6c2300274 100644 --- a/backend/src/emails/__snapshots__/sendWrongEmail.spec.ts.snap +++ b/backend/src/emails/__snapshots__/sendWrongEmail.spec.ts.snap @@ -99,6 +99,9 @@ footer {

– The ocelot.social Team

+
+

If you have questions or problems, feel free to contact our support: devops@ocelot.social

+
@@ -121,6 +124,9 @@ See you soon on ocelot.social [https://ocelot.social]! – The ocelot.social Team +If you have questions or problems, feel free to contact our support: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", @@ -226,6 +232,9 @@ footer {

– Dein ocelot.social Team

+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: devops@ocelot.social

+
@@ -248,6 +257,9 @@ Bis bald bei ocelot.social [https://ocelot.social]! – Dein ocelot.social Team +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +devops@ocelot.social [devops@ocelot.social] + ocelot.social Community [https://ocelot.social]", "to": "user@example.org", diff --git a/backend/src/emails/__snapshots__/supportLine.spec.ts.snap b/backend/src/emails/__snapshots__/supportLine.spec.ts.snap new file mode 100644 index 000000000..78dab2d41 --- /dev/null +++ b/backend/src/emails/__snapshots__/supportLine.spec.ts.snap @@ -0,0 +1,531 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`sendResetPasswordMail with support English renders correctly 1`] = ` +{ + "attachments": [], + "from": "ocelot.social ", + "html": " + + + + + + + + +
+
+
+
+
+

Hello Jenny Rostock,

+
+
+

So, you forgot your password? No problem! Just click the button below to reset it within the next 24 hours:

Confirm your e-mail address +

If you didn't request a new password feel free to ignore this e-mail.

+

If the above button doesn't work you can also copy the following code into your browser window: 123456

+
+

See you soon on ocelot.social!

+

– The ocelot.social Team

+
+
+
+

If you have questions or problems, feel free to contact our support: support@example.org

+
+ +
+ +", + "subject": "Reset Password ocelot.social", + "text": "HELLO JENNY ROSTOCK, + +So, you forgot your password? No problem! Just click the button below to reset +it within the next 24 hours: + +Confirm your e-mail address +[http://webapp:3000/password-reset/change-password?email=user%40example.org&nonce=123456] + +If you didn't request a new password feel free to ignore this e-mail. + +If the above button doesn't work you can also copy the following code into your +browser window: 123456 + +See you soon on ocelot.social [https://ocelot.social]! + +– The ocelot.social Team + +If you have questions or problems, feel free to contact our support: +support@example.org [support@example.org] + + +ocelot.social Community [https://ocelot.social]", + "to": "user@example.org", +} +`; + +exports[`sendResetPasswordMail with support German renders correctly 1`] = ` +{ + "attachments": [], + "from": "ocelot.social ", + "html": " + + + + + + + + +
+
+
+
+
+

Hallo Jenny Rostock,

+
+
+

Du hast also dein Passwort vergessen? Kein Problem! Mit Klick auf diesen Button kannst du innerhalb der nächsten 24 Stunden dein Passwort zurücksetzen:

Bestätige deine E-Mail Adresse +

Falls du kein neues Passwort angefordert hast, kannst du diese E-Mail einfach ignorieren.

+

Sollte der Button für dich nicht funktionieren, kannst du auch folgenden Code in dein Browserfenster kopieren: 123456

+
+

Bis bald bei ocelot.social!

+

– Dein ocelot.social Team

+
+
+
+

Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: support@example.org

+
+ +
+ +", + "subject": "Neues Passwort ocelot.social", + "text": "HALLO JENNY ROSTOCK, + +Du hast also dein Passwort vergessen? Kein Problem! Mit Klick auf diesen Button +kannst du innerhalb der nächsten 24 Stunden dein Passwort zurücksetzen: + +Bestätige deine E-Mail Adresse +[http://webapp:3000/password-reset/change-password?email=user%40example.org&nonce=123456] + +Falls du kein neues Passwort angefordert hast, kannst du diese E-Mail einfach +ignorieren. + +Sollte der Button für dich nicht funktionieren, kannst du auch folgenden Code in +dein Browserfenster kopieren: 123456 + +Bis bald bei ocelot.social [https://ocelot.social]! + +– Dein ocelot.social Team + +Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: +support@example.org [support@example.org] + + +ocelot.social Community [https://ocelot.social]", + "to": "user@example.org", +} +`; + +exports[`sendResetPasswordMail without support English renders correctly 1`] = ` +{ + "attachments": [], + "from": "ocelot.social ", + "html": " + + + + + + + + +
+
+
+
+
+

Hello Jenny Rostock,

+
+
+

So, you forgot your password? No problem! Just click the button below to reset it within the next 24 hours:

Confirm your e-mail address +

If you didn't request a new password feel free to ignore this e-mail.

+

If the above button doesn't work you can also copy the following code into your browser window: 123456

+
+

See you soon on ocelot.social!

+

– The ocelot.social Team

+
+
+ +
+ +", + "subject": "Reset Password ocelot.social", + "text": "HELLO JENNY ROSTOCK, + +So, you forgot your password? No problem! Just click the button below to reset +it within the next 24 hours: + +Confirm your e-mail address +[http://webapp:3000/password-reset/change-password?email=user%40example.org&nonce=123456] + +If you didn't request a new password feel free to ignore this e-mail. + +If the above button doesn't work you can also copy the following code into your +browser window: 123456 + +See you soon on ocelot.social [https://ocelot.social]! + +– The ocelot.social Team + + +ocelot.social Community [https://ocelot.social]", + "to": "user@example.org", +} +`; + +exports[`sendResetPasswordMail without support German renders correctly 1`] = ` +{ + "attachments": [], + "from": "ocelot.social ", + "html": " + + + + + + + + +
+
+
+
+
+

Hallo Jenny Rostock,

+
+
+

Du hast also dein Passwort vergessen? Kein Problem! Mit Klick auf diesen Button kannst du innerhalb der nächsten 24 Stunden dein Passwort zurücksetzen:

Bestätige deine E-Mail Adresse +

Falls du kein neues Passwort angefordert hast, kannst du diese E-Mail einfach ignorieren.

+

Sollte der Button für dich nicht funktionieren, kannst du auch folgenden Code in dein Browserfenster kopieren: 123456

+
+

Bis bald bei ocelot.social!

+

– Dein ocelot.social Team

+
+
+ +
+ +", + "subject": "Neues Passwort ocelot.social", + "text": "HALLO JENNY ROSTOCK, + +Du hast also dein Passwort vergessen? Kein Problem! Mit Klick auf diesen Button +kannst du innerhalb der nächsten 24 Stunden dein Passwort zurücksetzen: + +Bestätige deine E-Mail Adresse +[http://webapp:3000/password-reset/change-password?email=user%40example.org&nonce=123456] + +Falls du kein neues Passwort angefordert hast, kannst du diese E-Mail einfach +ignorieren. + +Sollte der Button für dich nicht funktionieren, kannst du auch folgenden Code in +dein Browserfenster kopieren: 123456 + +Bis bald bei ocelot.social [https://ocelot.social]! + +– Dein ocelot.social Team + + +ocelot.social Community [https://ocelot.social]", + "to": "user@example.org", +} +`; diff --git a/backend/src/emails/locales/de.json b/backend/src/emails/locales/de.json index 677c3b7f1..205a529b7 100644 --- a/backend/src/emails/locales/de.json +++ b/backend/src/emails/locales/de.json @@ -28,6 +28,7 @@ "introduction": "Du möchtest also deine E-Mail ändern? Kein Problem! Mit Klick auf diesen Button kannst du deine neue E-Mail Adresse bestätigen:", "doNotChange": "Falls du deine E-Mail Adresse doch nicht ändern möchtest, kannst du diese Nachricht einfach ignorieren. " }, + "support": "Wenn du Fragen oder Probleme hast, kannst du dich gerne an den Support wenden: ", "buttons": { "confirmEmail": "Bestätige deine E-Mail Adresse", "resetPassword": "Passwort zurücksetzen", diff --git a/backend/src/emails/locales/en.json b/backend/src/emails/locales/en.json index 30ca64655..97a45d3c7 100644 --- a/backend/src/emails/locales/en.json +++ b/backend/src/emails/locales/en.json @@ -28,6 +28,7 @@ "introduction": "So, you want to change your e-mail? No problem! Just click the button below to verify your new address:", "doNotChange": "If you don't want to change your e-mail address feel free to ignore this message. " }, + "support": "If you have questions or problems, feel free to contact our support: ", "buttons": { "confirmEmail": "Confirm your e-mail address", "resetPassword": "Reset password", diff --git a/backend/src/emails/sendEmail.ts b/backend/src/emails/sendEmail.ts index 6ed6d611f..61a5ba951 100644 --- a/backend/src/emails/sendEmail.ts +++ b/backend/src/emails/sendEmail.ts @@ -18,11 +18,12 @@ import { UserDbProperties } from '@db/types/User' const welcomeImageUrl = new URL(logosWebapp.LOGO_WELCOME_PATH, CONFIG.CLIENT_URI) const settingsUrl = new URL('/settings/notifications', CONFIG.CLIENT_URI) -const defaultParams = { +export const defaultParams = { welcomeImageUrl, APPLICATION_NAME: CONFIG.APPLICATION_NAME, ORGANIZATION_NAME: metadata.ORGANIZATION_NAME, ORGANIZATION_URL: CONFIG.ORGANIZATION_URL, + SUPPORT_EMAIL: CONFIG.SUPPORT_EMAIL, supportUrl: CONFIG.SUPPORT_URL, settingsUrl, renderSettingsUrl: true, diff --git a/backend/src/emails/supportLine.spec.ts b/backend/src/emails/supportLine.spec.ts new file mode 100644 index 000000000..c890be794 --- /dev/null +++ b/backend/src/emails/supportLine.spec.ts @@ -0,0 +1,67 @@ +import { sendResetPasswordMail, defaultParams } from './sendEmail' + +describe('sendResetPasswordMail', () => { + const data: { + email: string + nonce: string + locale: string + name: string + } = { + email: 'user@example.org', + nonce: '123456', + locale: 'en', + name: 'Jenny Rostock', + } + + describe('with support', () => { + beforeEach(() => { + defaultParams.SUPPORT_EMAIL = 'support@example.org' + }) + + describe('English', () => { + beforeEach(() => { + data.locale = 'en' + }) + + it('renders correctly', async () => { + await expect(sendResetPasswordMail(data)).resolves.toMatchSnapshot() + }) + }) + + describe('German', () => { + beforeEach(() => { + data.locale = 'de' + }) + + it('renders correctly', async () => { + await expect(sendResetPasswordMail(data)).resolves.toMatchSnapshot() + }) + }) + }) + + describe('without support', () => { + beforeEach(() => { + delete defaultParams.SUPPORT_EMAIL + }) + + describe('English', () => { + beforeEach(() => { + data.locale = 'en' + }) + + it('renders correctly', async () => { + await expect(sendResetPasswordMail(data)).resolves.toMatchSnapshot() + }) + }) + + describe('German', () => { + beforeEach(() => { + data.locale = 'de' + }) + + it('renders correctly', async () => { + await expect(sendResetPasswordMail(data)).resolves.toMatchSnapshot() + }) + }) + }) +}) diff --git a/backend/src/emails/templates/includes/support.pug b/backend/src/emails/templates/includes/support.pug new file mode 100644 index 000000000..49c73e844 --- /dev/null +++ b/backend/src/emails/templates/includes/support.pug @@ -0,0 +1,2 @@ +p= t('support') + a(href='mailto:' + supportEmail)= supportEmail \ No newline at end of file diff --git a/backend/src/emails/templates/layout.pug b/backend/src/emails/templates/layout.pug index faaadb5d3..4614f97be 100644 --- a/backend/src/emails/templates/layout.pug +++ b/backend/src/emails/templates/layout.pug @@ -27,4 +27,9 @@ html(lang=locale) block content include includes/greeting.pug + - var supportEmail = SUPPORT_EMAIL + if supportEmail + .support + include includes/support.pug + include includes/footer.pug