Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/firebase/env/dev/env_secrets.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"apiKey": "notrealapikey"
},
"mail": {
"SENDGRID_API_KEY": ""
"SENDGRID_API_KEY": "SG.Gxxxxx"
}
}
5 changes: 2 additions & 3 deletions packages/firebase/functions/src/notification/email/mailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ const SENDGRID_APIKEY = 'SENDGRID_APIKEY';
const setApiKey = async () => {
const apiKey = await getSecret(SENDGRID_APIKEY);
sendgrid.setApiKey(apiKey);
env.mail.SENDGRID_API_KEY = apiKey;
}

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

await sendgrid.send({
to: dest,
Expand Down