From 75e957ed4a17974295a9c7caae37aa7d5fe053be Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 30 Aug 2023 17:48:25 -0400 Subject: [PATCH 1/8] fix: missing variable in email templates --- app/controllers/api/account.php | 6 ++++-- app/controllers/api/teams.php | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 784c0dce76..a1e80e89ef 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2753,15 +2753,17 @@ App::post('/v1/account/verification') 'hello' => $locale->getText("emails.verification.hello"), 'name' => $user->getAttribute('name'), 'body' => $body, - 'redirect' => $url, 'footer' => $locale->getText("emails.verification.footer"), 'thanks' => $locale->getText("emails.verification.thanks"), 'signature' => $locale->getText("emails.verification.signature"), - 'project' => $projectName, 'direction' => $locale->getText('settings.direction'), 'bg-body' => '#f7f7f7', 'bg-content' => '#ffffff', 'text-content' => '#000000', + /* {{user}} ,{{team}}, {{project}} and {{redirect}} are required in the templates */ + 'user' => $user->getAttribute('name'), + 'project' => $projectName, + 'redirect' => $url ]; $mails diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index e53ef2c34a..1b9b8b6cab 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -599,7 +599,6 @@ App::post('/v1/teams/:teamId/memberships') $emailVariables = [ 'owner' => $user->getAttribute('name'), - 'team' => $team->getAttribute('name'), 'subject' => $subject, 'hello' => $locale->getText("emails.invitation.hello"), 'name' => $user->getAttribute('name'), @@ -613,6 +612,11 @@ App::post('/v1/teams/:teamId/memberships') 'bg-body' => '#f7f7f7', 'bg-content' => '#ffffff', 'text-content' => '#000000', + /* {{user}} ,{{team}}, {{project}} and {{redirect}} are required in the templates */ + 'user' => $user->getAttribute('name'), + 'team' => $team->getAttribute('name'), + 'project' => $projectName, + 'redirect' => $url ]; $mails From 05615d144932baec785416987c594fac354306f9 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 30 Aug 2023 17:52:55 -0400 Subject: [PATCH 2/8] fix: missing variable in email templates --- app/controllers/api/account.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index a1e80e89ef..c83d09a701 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1054,11 +1054,15 @@ App::post('/v1/account/sessions/magic-url') 'footer' => $locale->getText("emails.magicSession.footer"), 'thanks' => $locale->getText("emails.magicSession.thanks"), 'signature' => $locale->getText("emails.magicSession.signature"), - 'project' => $project->getAttribute('name'), 'direction' => $locale->getText('settings.direction'), 'bg-body' => '#f7f7f7', 'bg-content' => '#ffffff', 'text-content' => '#000000', + /* {{user}} ,{{team}}, {{project}} and {{redirect}} are required in the templates */ + 'user' => '', + 'team' => '', + 'project' => $project->getAttribute('name'), + 'redirect' => $url ]; $mails @@ -2503,15 +2507,18 @@ App::post('/v1/account/recovery') 'hello' => $locale->getText("emails.recovery.hello"), 'name' => $profile->getAttribute('name'), 'body' => $body, - 'redirect' => $url, 'footer' => $locale->getText("emails.recovery.footer"), 'thanks' => $locale->getText("emails.recovery.thanks"), 'signature' => $locale->getText("emails.recovery.signature"), - 'project' => $projectName, 'direction' => $locale->getText('settings.direction'), 'bg-body' => '#f7f7f7', 'bg-content' => '#ffffff', 'text-content' => '#000000', + /* {{user}} ,{{team}}, {{project}} and {{redirect}} are required in the templates */ + 'user' => $user->getAttribute('name'), + 'team' => '', + 'project' => $projectName, + 'redirect' => $url ]; @@ -2761,7 +2768,8 @@ App::post('/v1/account/verification') 'bg-content' => '#ffffff', 'text-content' => '#000000', /* {{user}} ,{{team}}, {{project}} and {{redirect}} are required in the templates */ - 'user' => $user->getAttribute('name'), + 'user' => $user->getAttribute('name'), + 'team' => '', 'project' => $projectName, 'redirect' => $url ]; From 74012158b3bd6d57b7a8fe6a33e93fdd2513f515 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 30 Aug 2023 17:54:26 -0400 Subject: [PATCH 3/8] fix: variable names --- app/controllers/api/account.php | 2 +- app/controllers/api/teams.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index c83d09a701..3f5b416596 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2515,7 +2515,7 @@ App::post('/v1/account/recovery') 'bg-content' => '#ffffff', 'text-content' => '#000000', /* {{user}} ,{{team}}, {{project}} and {{redirect}} are required in the templates */ - 'user' => $user->getAttribute('name'), + 'user' => $profile->getAttribute('name'), 'team' => '', 'project' => $projectName, 'redirect' => $url diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 1b9b8b6cab..6bc781e253 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -603,11 +603,9 @@ App::post('/v1/teams/:teamId/memberships') 'hello' => $locale->getText("emails.invitation.hello"), 'name' => $user->getAttribute('name'), 'body' => $body, - 'redirect' => $url, 'footer' => $locale->getText("emails.invitation.footer"), 'thanks' => $locale->getText("emails.invitation.thanks"), 'signature' => $locale->getText("emails.invitation.signature"), - 'project' => $projectName, 'direction' => $locale->getText('settings.direction'), 'bg-body' => '#f7f7f7', 'bg-content' => '#ffffff', From 861921526e350eb91372cabe70663d50f5080ed6 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 30 Aug 2023 18:34:20 -0400 Subject: [PATCH 4/8] fix: remove redundant name property --- app/controllers/api/account.php | 3 --- app/controllers/api/teams.php | 1 - app/workers/mails.php | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 3f5b416596..311aa1b68d 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1048,7 +1048,6 @@ App::post('/v1/account/sessions/magic-url') $emailVariables = [ 'subject' => $subject, 'hello' => $locale->getText("emails.magicSession.hello"), - 'name' => '', 'body' => $body, 'redirect' => $url, 'footer' => $locale->getText("emails.magicSession.footer"), @@ -2505,7 +2504,6 @@ App::post('/v1/account/recovery') $emailVariables = [ 'subject' => $subject, 'hello' => $locale->getText("emails.recovery.hello"), - 'name' => $profile->getAttribute('name'), 'body' => $body, 'footer' => $locale->getText("emails.recovery.footer"), 'thanks' => $locale->getText("emails.recovery.thanks"), @@ -2758,7 +2756,6 @@ App::post('/v1/account/verification') $emailVariables = [ 'subject' => $subject, 'hello' => $locale->getText("emails.verification.hello"), - 'name' => $user->getAttribute('name'), 'body' => $body, 'footer' => $locale->getText("emails.verification.footer"), 'thanks' => $locale->getText("emails.verification.thanks"), diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 6bc781e253..23ce9f3246 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -601,7 +601,6 @@ App::post('/v1/teams/:teamId/memberships') 'owner' => $user->getAttribute('name'), 'subject' => $subject, 'hello' => $locale->getText("emails.invitation.hello"), - 'name' => $user->getAttribute('name'), 'body' => $body, 'footer' => $locale->getText("emails.invitation.footer"), 'thanks' => $locale->getText("emails.invitation.thanks"), diff --git a/app/workers/mails.php b/app/workers/mails.php index 9ef26af0f1..2edf6957a2 100644 --- a/app/workers/mails.php +++ b/app/workers/mails.php @@ -35,9 +35,9 @@ class MailsV1 extends Worker $recipient = $this->args['recipient']; $subject = $this->args['subject']; - $name = $this->args['name']; $body = $this->args['body']; $variables = $this->args['variables']; + $name = $variables['name'] ?? ''; $body = Template::fromFile(__DIR__ . '/../config/locale/templates/email-base.tpl'); From 21dc3b16b001a98ebe796f1d2d47f7d1d92f7ecd Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 30 Aug 2023 18:36:40 -0400 Subject: [PATCH 5/8] chore: update changelog --- CHANGES.md | 5 +++++ app/controllers/api/teams.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 864784259b..8877d4b4e4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +# Version 1.4.1 + +## Fixes +- Add missing parameters required for custom email templates [#6077](https://github.com/appwrite/appwrite/pull/6077) + # Version 1.4.0 ## Features diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 23ce9f3246..c5dd3eed12 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -610,7 +610,7 @@ App::post('/v1/teams/:teamId/memberships') 'bg-content' => '#ffffff', 'text-content' => '#000000', /* {{user}} ,{{team}}, {{project}} and {{redirect}} are required in the templates */ - 'user' => $user->getAttribute('name'), + 'user' => $user->getAttribute('name'), 'team' => $team->getAttribute('name'), 'project' => $projectName, 'redirect' => $url From 997cb01142d00f1c697241dfeef081559f6fa993 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 30 Aug 2023 18:42:31 -0400 Subject: [PATCH 6/8] chore: revert console --- app/console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/console b/app/console index bfd14ef923..88b6d59051 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit bfd14ef923e57938639e95e5ab32e68d49e24407 +Subproject commit 88b6d59051992ed86183ee83d77bf678d1cb73bf From 5dbec3d40676422d8614cc2eeb9887737ac0e71b Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 30 Aug 2023 18:43:09 -0400 Subject: [PATCH 7/8] chore: remove redundant attribute --- app/controllers/api/account.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 311aa1b68d..c6df38c3ca 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1049,7 +1049,6 @@ App::post('/v1/account/sessions/magic-url') 'subject' => $subject, 'hello' => $locale->getText("emails.magicSession.hello"), 'body' => $body, - 'redirect' => $url, 'footer' => $locale->getText("emails.magicSession.footer"), 'thanks' => $locale->getText("emails.magicSession.thanks"), 'signature' => $locale->getText("emails.magicSession.signature"), From 61e1c3014a04c7e961cb7b615dc275e1a3e5eea7 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 30 Aug 2023 18:44:29 -0400 Subject: [PATCH 8/8] fix: incorrect key reference --- app/workers/mails.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/workers/mails.php b/app/workers/mails.php index 2edf6957a2..27d8f85f04 100644 --- a/app/workers/mails.php +++ b/app/workers/mails.php @@ -37,7 +37,7 @@ class MailsV1 extends Worker $subject = $this->args['subject']; $body = $this->args['body']; $variables = $this->args['variables']; - $name = $variables['name'] ?? ''; + $name = $variables['user'] ?? ''; $body = Template::fromFile(__DIR__ . '/../config/locale/templates/email-base.tpl');