Skip to content

Commit a541431

Browse files
committed
CM-1485-do not call setSecret (#333)
1 parent fdeb2f1 commit a541431

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/common-firebase/env/dev/env_secrets.dev.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"apiKey": "notrealapikey"
44
},
55
"mail": {
6-
"SENDGRID_API_KEY": "SG.Gxxxxx"
6+
"SENDGRID_API_KEY": ""
77
}
88
}

packages/common-firebase/functions/src/notification/email/mailer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ const SENDGRID_APIKEY = 'SENDGRID_APIKEY';
88
const setApiKey = async () => {
99
const apiKey = await getSecret(SENDGRID_APIKEY);
1010
sendgrid.setApiKey(apiKey);
11+
env.mail.SENDGRID_API_KEY = apiKey;
1112
}
1213

1314
export const sendMail = async (dest: string, subject: string, message: string, from = env.mail.sender, bcc = null): Promise<void> => {
14-
// @question Moore, why are we awaiting this on every single mail we send?
15-
await setApiKey();
15+
// if env.mail.SENDGRID_API_KEY has no value, set it with apiKey
16+
!env.mail.SENDGRID_API_KEY && await setApiKey();
1617

1718
await sendgrid.send({
1819
to: dest,

0 commit comments

Comments
 (0)