From 38cd67f881a0666c51739031ce898b3cd4e05eea Mon Sep 17 00:00:00 2001 From: ClaraCrazy Date: Sun, 29 Sep 2024 10:20:20 +0200 Subject: [PATCH] Fix missing subject issues --- application/imap-service.js | 2 ++ infrastructure/web/routes/inbox.js | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/application/imap-service.js b/application/imap-service.js index 190ae2c..1123ec8 100644 --- a/application/imap-service.js +++ b/application/imap-service.js @@ -254,6 +254,8 @@ class ImapService extends EventEmitter { .map(addressObj => addressObj.address) const from = headerPart.from.flatMap(from => addressparser(from)) + + // Specify default subject, in case none exists. let subject = "No Subject" try { subject = headerPart.subject[0] diff --git a/infrastructure/web/routes/inbox.js b/infrastructure/web/routes/inbox.js index 04cf3f3..f99f535 100644 --- a/infrastructure/web/routes/inbox.js +++ b/infrastructure/web/routes/inbox.js @@ -33,6 +33,12 @@ router.get( req.params.uid ) if (mail) { + + // Set a default subject if none is present + if (!mail.subject) { + mail.subject = 'No Subject' + } + // Emails are immutable, cache if found res.set('Cache-Control', 'private, max-age=600') res.render('mail', {