mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
fix dependecies
This commit is contained in:
parent
7b714e7bc3
commit
6ea5bc3b18
3 changed files with 19 additions and 19 deletions
|
|
@ -10,6 +10,7 @@ import {
|
|||
handleConfirmation,
|
||||
isConfirmationEmail,
|
||||
NewsletterHandler,
|
||||
parseUnsubscribe,
|
||||
} from './newsletter'
|
||||
import { PubSub } from '@google-cloud/pubsub'
|
||||
import { handlePdfAttachment } from './pdf'
|
||||
|
|
@ -19,16 +20,8 @@ import { BloombergHandler } from './bloomberg-handler'
|
|||
import { GolangHandler } from './golang-handler'
|
||||
import { MorningBrewHandler } from './morning-brew-handler'
|
||||
|
||||
interface Unsubscribe {
|
||||
mailTo?: string
|
||||
httpUrl?: string
|
||||
}
|
||||
|
||||
const NON_NEWSLETTER_EMAIL_TOPIC = 'nonNewsletterEmailReceived'
|
||||
const pubsub = new PubSub()
|
||||
const UNSUBSCRIBE_HTTP_URL_PATTERN = /<(https?:\/\/[^>]*)>/
|
||||
const UNSUBSCRIBE_MAIL_TO_PATTERN = /<mailto:([^>]*)>/
|
||||
|
||||
const NEWSLETTER_HANDLERS = [
|
||||
new SubstackHandler(),
|
||||
new AxiosHandler(),
|
||||
|
|
@ -37,15 +30,6 @@ const NEWSLETTER_HANDLERS = [
|
|||
new MorningBrewHandler(),
|
||||
]
|
||||
|
||||
export const parseUnsubscribe = (unSubHeader: string): Unsubscribe => {
|
||||
// parse list-unsubscribe header
|
||||
// e.g. List-Unsubscribe: <https://omnivore.com/unsub>, <mailto:unsub@omnivore.com>
|
||||
return {
|
||||
mailTo: unSubHeader.match(UNSUBSCRIBE_MAIL_TO_PATTERN)?.[1],
|
||||
httpUrl: unSubHeader.match(UNSUBSCRIBE_HTTP_URL_PATTERN)?.[1],
|
||||
}
|
||||
}
|
||||
|
||||
export const getNewsletterHandler = (
|
||||
postHeader: string,
|
||||
from: string,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
import { PubSub } from '@google-cloud/pubsub'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import addressparser from 'addressparser'
|
||||
import { parseUnsubscribe } from './index'
|
||||
|
||||
interface Unsubscribe {
|
||||
mailTo?: string
|
||||
httpUrl?: string
|
||||
}
|
||||
|
||||
const pubsub = new PubSub()
|
||||
const NEWSLETTER_EMAIL_RECEIVED_TOPIC = 'newsletterEmailReceived'
|
||||
|
|
@ -10,6 +14,17 @@ const EMAIL_FORWARDING_SENDER_ADDRESSES = [
|
|||
'Gmail Team <forwarding-noreply@google.com>',
|
||||
]
|
||||
const CONFIRMATION_CODE_PATTERN = /^\(#\d+\)/
|
||||
const UNSUBSCRIBE_HTTP_URL_PATTERN = /<(https?:\/\/[^>]*)>/
|
||||
const UNSUBSCRIBE_MAIL_TO_PATTERN = /<mailto:([^>]*)>/
|
||||
|
||||
export const parseUnsubscribe = (unSubHeader: string): Unsubscribe => {
|
||||
// parse list-unsubscribe header
|
||||
// e.g. List-Unsubscribe: <https://omnivore.com/unsub>, <mailto:unsub@omnivore.com>
|
||||
return {
|
||||
mailTo: unSubHeader.match(UNSUBSCRIBE_MAIL_TO_PATTERN)?.[1],
|
||||
httpUrl: unSubHeader.match(UNSUBSCRIBE_HTTP_URL_PATTERN)?.[1],
|
||||
}
|
||||
}
|
||||
|
||||
export class NewsletterHandler {
|
||||
protected senderRegex = /NEWSLETTER_SENDER_REGEX/
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ import {
|
|||
getConfirmationCode,
|
||||
isConfirmationEmail,
|
||||
NewsletterHandler,
|
||||
parseUnsubscribe,
|
||||
} from '../src/newsletter'
|
||||
import { SubstackHandler } from '../src/substack-handler'
|
||||
import { AxiosHandler } from '../src/axios-handler'
|
||||
import { BloombergHandler } from '../src/bloomberg-handler'
|
||||
import { GolangHandler } from '../src/golang-handler'
|
||||
import { getNewsletterHandler, parseUnsubscribe } from '../src'
|
||||
import { getNewsletterHandler } from '../src'
|
||||
import { MorningBrewHandler } from '../src/morning-brew-handler'
|
||||
|
||||
describe('Confirmation email test', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue