From dd4ae5e9b99d8f86c23b0eb944443973a5f8416e Mon Sep 17 00:00:00 2001 From: Linda Goldstein Date: Wed, 2 Oct 2024 15:06:31 +0200 Subject: [PATCH] Add ability to show bcc recipients if present, and not error on missing to recipient --- app.js | 6 +++++- test/app.test.js | 13 +++++++++++++ views/index.pug | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 47d05de..51b1f4e 100644 --- a/app.js +++ b/app.js @@ -106,7 +106,9 @@ async function createEmail(message) { return { timestamp: message.Timestamp, subject: parsed.subject, - to: parsed.to.text, + to: parsed.to?.text, + cc: parsed.cc?.text, + bcc: parsed.bcc?.text, html: parsed.html, attachments: parsed.attachments, isDownloadable: true, @@ -117,6 +119,8 @@ async function createEmail(message) { timestamp: message.Timestamp, subject: message.Subject, to: message.Destination.ToAddresses, + cc: message.Destination.CcAddresses, + bcc: message.Destination.BccAddresses, html: message.Body.html_part ?? message.Body.text_part, attachments: [], isDownloadable: false, diff --git a/test/app.test.js b/test/app.test.js index c047334..6a89b2f 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -43,6 +43,19 @@ describe("App Tests", () => { html_part: null, }, }, + { + Timestamp: Date.now(), + Subject: "Test email CC and BCC only", + Destination: { + ToAddresses: [], + CcAddresses: ['cc@example.com'], + BccAddresses: ['bcc@example.com'] + }, + Body: { + text_part: "This is a test email with only CC and BCC recipients", + html_part: null, + }, + }, ], }); }); diff --git a/views/index.pug b/views/index.pug index c164f6d..8686b58 100644 --- a/views/index.pug +++ b/views/index.pug @@ -48,6 +48,8 @@ html each column in extraColumns th= column.name th To + th CC + th BCC th Subject th th @@ -62,6 +64,8 @@ html if logo img(src=`data:image/png;base64,${logo.toString('base64')}`, height="24px", alt="Logo") td= message.to + td= message.cc + td= message.bcc td= message.subject td a(href='/emails/' + message.id) View