Merge pull request #2097 from omnivore-app/fix/unsubscribe-header

Fix list-unsubscribe header undefined
This commit is contained in:
Hongbo Wu 2023-04-22 15:13:05 +08:00 committed by GitHub
commit c3366c6238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -172,9 +172,9 @@ export abstract class ContentHandler {
const url =
(await this.parseNewsletterUrl(headers, html)) || generateUniqueUrl()
const author = this.parseAuthor(from)
const unsubscribe = this.parseUnsubscribe(
headers['list-unsubscribe']?.toString()
)
const unsubscribe = headers['list-unsubscribe']
? this.parseUnsubscribe(headers['list-unsubscribe'].toString())
: undefined
return {
email: to,
@ -182,8 +182,8 @@ export abstract class ContentHandler {
url,
title: subject,
author,
unsubMailTo: unsubscribe.mailTo || '',
unsubHttpUrl: unsubscribe.httpUrl || '',
unsubMailTo: unsubscribe?.mailTo || '',
unsubHttpUrl: unsubscribe?.httpUrl || '',
}
}
}

View file

@ -189,7 +189,13 @@ export const inboundEmailHandler = Sentry.GCPFunction.wrapHttpFunction(
})
res.send('newsletter received')
} catch (error) {
console.log('error handling emails, will forward.', from, to, subject)
console.log(
'error handling emails, will forward.',
from,
to,
subject,
error
)
// queue error emails
await pubsub.topic(NON_NEWSLETTER_EMAIL_TOPIC).publishMessage({
json: {