handle undefined envelope
This commit is contained in:
parent
2e8f6a1d14
commit
904a38ce1f
@ -159,10 +159,10 @@ const fetchMessages = (
|
|||||||
*/
|
*/
|
||||||
type EmailMatcher = (email: Email) => (message: FetchMessageObject) => boolean;
|
type EmailMatcher = (email: Email) => (message: FetchMessageObject) => boolean;
|
||||||
const matchesEmail: EmailMatcher = (email) => (message) => {
|
const matchesEmail: EmailMatcher = (email) => (message) => {
|
||||||
const subjectMatches = email.subject === message.envelope.subject;
|
const subjectMatches = email.subject === message.envelope?.subject;
|
||||||
const bodyMatches =
|
const bodyMatches =
|
||||||
message.bodyParts.get("text")?.toString().trim() === email.text.trim();
|
message.bodyParts?.get("text")?.toString().trim() === email.text.trim();
|
||||||
const headers = message.headers.toLocaleString();
|
const headers = message.headers?.toLocaleString();
|
||||||
const fromMatches = headers.includes(`Return-Path: <${email.from}>`);
|
const fromMatches = headers.includes(`Return-Path: <${email.from}>`);
|
||||||
const toMatches = headers.includes(`Delivered-To: ${email.to}`);
|
const toMatches = headers.includes(`Delivered-To: ${email.to}`);
|
||||||
return subjectMatches && bodyMatches && fromMatches && toMatches;
|
return subjectMatches && bodyMatches && fromMatches && toMatches;
|
||||||
|
Loading…
Reference in New Issue
Block a user