From 8a4227bcb73a189afda4b7841e8be41a74048940 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 12 Jun 2020 01:20:32 +0200 Subject: [PATCH] add responsive email templates --- app/config/locales/templates/_base.tpl | 234 ++++++++++++++++++ app/config/locales/templates/_cta.tpl | 19 ++ .../templates/en.email.auth.confirm.tpl | 39 ++- .../templates/en.email.auth.invitation.tpl | 41 ++- .../templates/en.email.auth.recovery.tpl | 39 ++- app/controllers/api/account.php | 16 +- app/controllers/api/teams.php | 9 +- 7 files changed, 319 insertions(+), 78 deletions(-) create mode 100644 app/config/locales/templates/_base.tpl create mode 100644 app/config/locales/templates/_cta.tpl diff --git a/app/config/locales/templates/_base.tpl b/app/config/locales/templates/_base.tpl new file mode 100644 index 0000000000..57051e67a3 --- /dev/null +++ b/app/config/locales/templates/_base.tpl @@ -0,0 +1,234 @@ + + + + + + + {{title}} + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/config/locales/templates/_cta.tpl b/app/config/locales/templates/_cta.tpl new file mode 100644 index 0000000000..6cb2380e8d --- /dev/null +++ b/app/config/locales/templates/_cta.tpl @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/app/config/locales/templates/en.email.auth.confirm.tpl b/app/config/locales/templates/en.email.auth.confirm.tpl index 92078114e3..a9afe29503 100644 --- a/app/config/locales/templates/en.email.auth.confirm.tpl +++ b/app/config/locales/templates/en.email.auth.confirm.tpl @@ -1,24 +1,15 @@ - - -
- Hello {{name}}, -
-
- Follow this link to verify your email address. -
- {{redirect}} -
-
- If you didn’t ask to verify this address, you can ignore this message. -
-
- Thanks, -
- {{project}} team -
\ No newline at end of file +

+ Hello {{name}}, +

+

+ Follow this link to verify your email address. +

+{{cta}} +

+ If you didn’t ask to verify this address, you can ignore this message. +

+

+ Thanks, +
+ {{project}} team +

\ No newline at end of file diff --git a/app/config/locales/templates/en.email.auth.invitation.tpl b/app/config/locales/templates/en.email.auth.invitation.tpl index fda2bbcce0..5ea1f11891 100644 --- a/app/config/locales/templates/en.email.auth.invitation.tpl +++ b/app/config/locales/templates/en.email.auth.invitation.tpl @@ -1,27 +1,14 @@ - - -
- Hello, -
-
- This mail was sent to you because {{owner}} wanted to invite you to become a team member at the {{team}} team over at {{project}}. -
-
- Follow this link to join the {{team}} team: -
- {{redirect}} -
-
- If you are not interested, you can ignore this message. -
-
- Thanks, -
- {{project}} team -
+

+ Hello {{name}}, +

+

+ This mail was sent to you because {{owner}} wanted to invite you to become a team member at the {{team}} team over at {{project}}. +

+{{cta}} +

+ If you are not interested, you can ignore this message.

+

+ Thanks, +
+ {{project}} team +

\ No newline at end of file diff --git a/app/config/locales/templates/en.email.auth.recovery.tpl b/app/config/locales/templates/en.email.auth.recovery.tpl index 82b365546a..fb7ad67eb0 100644 --- a/app/config/locales/templates/en.email.auth.recovery.tpl +++ b/app/config/locales/templates/en.email.auth.recovery.tpl @@ -1,24 +1,15 @@ - - -
- Hello {{name}}, -
-
- Follow this link to reset your {{project}} password. -
- {{redirect}} -
-
- If you didn't ask to reset your password, you can ignore this message. -
-
- Thanks, -
- {{project}} team -
+

+ Hello {{name}}, +

+

+ Follow this link to reset your {{project}} password. +

+{{cta}} +

+ If you didn’t ask to verify this address, you can ignore this message. +

+

+ Thanks, +
+ {{project}} team +

\ No newline at end of file diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index ce19865264..ee7896f096 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1074,8 +1074,14 @@ $utopia->post('/v1/account/recovery') $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $profile->getId(), 'secret' => $secret]); $url = Template::unParseURL($url); - $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.recovery.body')); + $body = new Template(__DIR__.'/../../config/locales/templates/_base.tpl'); + $content = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.recovery.body')); + $cta = new Template(__DIR__.'/../../config/locales/templates/_cta.tpl'); + $body + ->setParam('{{content}}', $content->render()) + ->setParam('{{cta}}', $cta->render()) + ->setParam('{{title}}', Locale::getText('account.emails.recovery.title')) ->setParam('{{direction}}', Locale::getText('settings.direction')) ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) ->setParam('{{name}}', $profile->getAttribute('name')) @@ -1223,8 +1229,14 @@ $utopia->post('/v1/account/verification') $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $user->getId(), 'secret' => $verificationSecret]); $url = Template::unParseURL($url); - $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.verification.body')); + $body = new Template(__DIR__.'/../../config/locales/templates/_base.tpl'); + $content = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.verification.body')); + $cta = new Template(__DIR__.'/../../config/locales/templates/_cta.tpl'); + $body + ->setParam('{{content}}', $content->render()) + ->setParam('{{cta}}', $cta->render()) + ->setParam('{{title}}', Locale::getText('account.emails.verification.title')) ->setParam('{{direction}}', Locale::getText('settings.direction')) ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) ->setParam('{{name}}', $user->getAttribute('name')) diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index ccea694833..4fb67a0022 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -316,12 +316,19 @@ $utopia->post('/v1/teams/:teamId/memberships') $url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['inviteId' => $membership->getId(), 'teamId' => $team->getId(), 'userId' => $invitee->getId(), 'secret' => $secret, 'teamId' => $teamId]); $url = Template::unParseURL($url); - $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.invitation.body')); + $body = new Template(__DIR__.'/../../config/locales/templates/_base.tpl'); + $content = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.invitation.body')); + $cta = new Template(__DIR__.'/../../config/locales/templates/_cta.tpl'); + $body + ->setParam('{{content}}', $content->render()) + ->setParam('{{cta}}', $cta->render()) + ->setParam('{{title}}', Locale::getText('account.emails.invitation.title')) ->setParam('{{direction}}', Locale::getText('settings.direction')) ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) ->setParam('{{team}}', $team->getAttribute('name', '[TEAM-NAME]')) ->setParam('{{owner}}', $user->getAttribute('name', '')) + ->setParam('{{name}}', $name) ->setParam('{{redirect}}', $url) ;