summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-12-15 12:10:02 -0800
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-12-15 12:22:23 -0800
commit8e5fabec3e216ef55927909368c4013235fba729 (patch)
tree54cfbb03727594c3e0dd02f9c1caef505e528fde
parent2e8f6a1d14a574cc99c4eacfc4ba94cd92c64d99 (diff)
downloaduptime-8e5fabec3e216ef55927909368c4013235fba729.tar.gz
uptime-8e5fabec3e216ef55927909368c4013235fba729.zip
handle undefined envelope
-rw-r--r--src/email.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/email.ts b/src/email.ts
index 0e4bd88..cf588f4 100644
--- a/src/email.ts
+++ b/src/email.ts
@@ -159,10 +159,10 @@ const fetchMessages = (
*/
type EmailMatcher = (email: Email) => (message: FetchMessageObject) => boolean;
const matchesEmail: EmailMatcher = (email) => (message) => {
- const subjectMatches = email.subject === message.envelope.subject;
+ const subjectMatches = email.subject === message.envelope?.subject;
const bodyMatches =
- message.bodyParts.get("text")?.toString().trim() === email.text.trim();
- const headers = message.headers.toLocaleString();
+ message.bodyParts?.get("text")?.toString().trim() === email.text.trim();
+ const headers = message.headers?.toLocaleString();
const fromMatches = headers.includes(`Return-Path: <${email.from}>`);
const toMatches = headers.includes(`Delivered-To: ${email.to}`);
return subjectMatches && bodyMatches && fromMatches && toMatches;