Save subscriptions when saving newsletters (#447)

* parse unsub mailTo or httpUrl and send to pubsub

* save subscription from newsletter

* fix tests
This commit is contained in:
Hongbo Wu
2022-04-20 09:24:40 +08:00
committed by GitHub
parent 48e36c8635
commit 5c7f4a22bf
9 changed files with 144 additions and 34 deletions

View File

@ -7,15 +7,19 @@ export class SubstackHandler extends NewsletterHandler {
this.defaultUrl = 'https://www.substack.com'
}
getNewsletterUrl(rawUrl: string, _html: string): string | undefined {
getNewsletterUrl(postHeader: string, _html: string): string | undefined {
// raw SubStack newsletter url is like <https://hongbo130.substack.com/p/tldr>
// we need to get the real url from the raw url
return addressparser(rawUrl).length > 0
? addressparser(rawUrl)[0].name
return addressparser(postHeader).length > 0
? addressparser(postHeader)[0].name
: undefined
}
isNewsletter(rawUrl: string, _from: string, _unSubRawUrl: string): boolean {
return !!rawUrl
isNewsletter(
postHeader: string,
_from: string,
_unSubHeader: string
): boolean {
return !!postHeader
}
}