Skip to content

Commit 731353b

Browse files
committed
polish(auth): Add allow list for new fxa mailer sending
1 parent a5fb588 commit 731353b

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

packages/fxa-auth-server/config/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,7 @@ const convictConf = convict({
597597
ignoreTemplates: {
598598
doc: 'Always ignore bounces from these email templates',
599599
format: Array,
600-
default: [
601-
'verifyLoginCode',
602-
'verifyLogin',
603-
'recovery',
604-
'unblockCode',
605-
],
600+
default: ['verifyLoginCode', 'verifyLogin', 'recovery', 'unblockCode'],
606601
env: 'BOUNCES_IGNORE_TEMPLATES',
607602
},
608603
deleteAccount: {
@@ -682,6 +677,12 @@ const convictConf = convict({
682677
default: true,
683678
env: 'SMTP_METRICS_ENABLED',
684679
},
680+
fxaMailerDisableSend: {
681+
doc: 'Array of templates that should not be supported by fxa mailer. Used to fallback to previous email sending if in a pinch.',
682+
format: Array,
683+
default: [''],
684+
env: 'SMTP_FXA_MAILER_DISABLE_SEND',
685+
},
685686
},
686687
maxEventLoopDelay: {
687688
doc: 'Max event-loop delay before which incoming requests are rejected',

packages/fxa-auth-server/lib/senders/fxa-mailer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ export class FxaMailer extends FxaEmailRenderer {
5353
super(bindings);
5454
}
5555

56+
/**
57+
* Feature flag esque method that signals if the template is supported by the new mailer. Used to easily
58+
* fall back to old email code if necessary.
59+
* @param templateName The name of the template to check on.
60+
* @returns True if the email can be sent, and false if the template is included in the SMTP_FXA_MAILER_DISABLE_SEND list.
61+
*/
62+
canSend(templateName: string) {
63+
if (this.mailerConfig.fxaMailerDisableSend.includes(templateName)) {
64+
return false;
65+
}
66+
return true;
67+
}
68+
5669
async sendRecoveryEmail(
5770
opts: EmailSenderOpts &
5871
OmitCommonLinks<TemplateData> &

0 commit comments

Comments
 (0)