Skip to content

Commit

Permalink
add [DEV] and [STAGING] tags to emails
Browse files Browse the repository at this point in the history
  • Loading branch information
lucia-gomez committed Apr 6, 2024
1 parent 9338ea7 commit c665be9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions media_commons_booking_app/src/server/emails.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Booking, BookingStatusLabel } from '../types';
import { Booking, BookingStatusLabel, DevBranch } from '../types';

export const sendTextEmail = (
targetEmail: string,
Expand All @@ -10,6 +10,17 @@ export const sendTextEmail = (
GmailApp.sendEmail(targetEmail, subj, body);
};

const getEmailBranchTag = () => {
switch (process.env.BRANCH_NAME as DevBranch) {
case 'development':
return '[DEV] ';
case 'staging':
return '[STAGING] ';
default:
return '';
}
};

export const sendHTMLEmail = (
templateName: string,
contents: Booking,
Expand All @@ -19,7 +30,7 @@ export const sendHTMLEmail = (
body
) => {
console.log('contents', contents);
const subj = `${status}: Media Commons request for \"${eventTitle}\"`;
const subj = `${getEmailBranchTag()}${status}: Media Commons request for \"${eventTitle}\"`;
const htmlTemplate = HtmlService.createTemplateFromFile(templateName);
for (const key in contents) {
htmlTemplate[key] = contents[key] || '';
Expand Down

0 comments on commit c665be9

Please sign in to comment.