diff --git a/api/services/emailService.ts b/api/services/emailService.ts index d0783870e..5a418fbf7 100644 --- a/api/services/emailService.ts +++ b/api/services/emailService.ts @@ -160,6 +160,43 @@ export async function sendInvitationEmail(params: ISendInvitationEmailAttrs) { return sendEmail(email); } +export async function sendNewCommentEmailToCampaignAdminAsync (emails: string[], newContributionComments: string[], newExpenditureComments: string[], contributionComments: string, expendituresComments: string): Promise { + const host = process.env.HOST_URL || 'http://localhost:3000'; + const email: ISESEmailParams = { + Destination: { + ToAddresses: emails, + CcAddresses: ['OpenElections@portlandoregon.gov'], + }, + Message: { + Body: { + Html: { + Charset: 'UTF-8', + Data: commentEmailHtml(newContributionComments, newExpenditureComments) + }, + Text: { + Charset: 'UTF-8', + Data: 'This is a daily transaction summary for your campaign\'s Contribution and Expenditure comments.\r\n' + + `${contributionComments.replace(new RegExp('

', 'g'), '\r\n\r\n').replace(new RegExp('
', 'g'), '\r\n')}\r\n` + + `${expendituresComments.replace(new RegExp('

', 'g'), '\r\n\r\n').replace(new RegExp('
', 'g'), '\r\n')}\r\n` + + 'In accordance with Portland City Code 2.16.170, if you believe a determination was made in error, you may file a Request for Reconsideration with the Director within seven days of this notification being sent. You may make this request by filling out a Request for Reconsideration form on the program website at www.portlandoregon.gov/OAE and submitting it to OpenElections@portlandoregon.gov.\r\n' + + `If you would like more information about the transaction(s), please go to your campaign portal at ${host}.\r\n` + + 'Sincerely,\r\n' + + 'Susan Mottet\r\n' + + 'Director, Open and Accountable Elections\r\n' + + 'https://www.portlandoregon.gov/OAE' + }, + }, + Subject: { + Charset: 'UTF-8', + Data: `Important message from the City's OAE program about a transaction`, + } + }, + Source: 'no-reply@openelectionsportland.org', + ReplyToAddresses: ['susan.Mottet@portlandoregon.gov'] + }; + return sendEmail(email); +} + export async function sendActivityEmailToCampaignAdminsAsync(campaignId: number): Promise { const to: Date = new Date(); @@ -255,6 +292,7 @@ export async function sendActivityEmailToCampaignAdminsAsync(campaignId: number) Source: 'no-reply@openelectionsportland.org', ReplyToAddresses: ['susan.Mottet@portlandoregon.gov'] }; + await sendNewCommentEmailToCampaignAdminAsync(emails, newContributionComments, newExpenditureComments, contributionComments, expendituresComments); return sendEmail(email); } @@ -880,7 +918,7 @@ export function summaryEmailHtml(newContributionUpdates, newExpenditureUpdates, - The following expenditures have been commented on in the last 24 hours + The following expenditures have been commented on in the last 24 hours: ${newExpenditureUpdates.filter(item => !!item && item.trim() !== '').map((item: string): string => { @@ -969,5 +1007,167 @@ export function summaryEmailHtml(newContributionUpdates, newExpenditureUpdates, -`; } +`; +} +export function commentEmailHtml(newContributionComments, newExpenditureComments) { + const host = process.env.HOST_URL || 'http://localhost:3000'; + return ` + + + + 24 Hr Summary Email + + + + + + + + + + +
+ + +
+ + + + +
+ + + Open & Accountable Elections Portland +
+ + +
+ + + + + ${newContributionComments.filter(item => !!item && item.trim() !== '') && ( + ` + + + + + ` + )} + ${newContributionComments.filter(item => !!item && item.trim() !== '').map((item: string): string => { + return ``; + })} + ${newExpenditureComments.filter(item => !!item && item.trim() !== '') && ( + ` + + + + + ` + )} + ${newExpenditureComments.filter(item => !!item && item.trim() !== '').map((item: string): string => { + return ``; + })} + + + + + + + + + + + + + + + + + + +
+ This is a daily summary for your campaign's Contribution and Expenditure comments. +
+ Contribution Comments +
+ The following contributions have been commented on in the last 24 hours: +
${item}
+ Expenditure Comments +
+ The following expenditures have been commented on in the last 24 hours: +
${item}
+ In accordance with Portland City Code 2.16.170, if you believe a determination was made in error, you may file a Request for Reconsideration with the Director within seven days of this notification being sent. You may make this request by filling out a Request for Reconsideration form on the program website at https://www.portlandoregon.gov/OAE and submitting it to OpenElections@portlandoregon.gov. +
+ If you would like more information about the transaction(s), please go to your campaign portal. +
+ Sincerely, +
+ Susan Mottet +
+ Director, Open and Accountable Elections +
+ + https://www.portlandoregon.gov/OAE +
+
+ + + + + +`; +}