mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #1028 from omnivore-app/fix/dont-fetch-stub-urls
When parsing newsletters with no url dont fetch the generated url
This commit is contained in:
commit
838c6567c1
2 changed files with 13 additions and 3 deletions
|
|
@ -1,5 +1,9 @@
|
|||
import { generateSlug, stringToHash, validatedDate } from '../utils/helpers'
|
||||
import { parsePreparedContent, parseUrlMetadata } from '../utils/parser'
|
||||
import {
|
||||
FAKE_URL_PREFIX,
|
||||
parsePreparedContent,
|
||||
parseUrlMetadata,
|
||||
} from '../utils/parser'
|
||||
import normalizeUrl from 'normalize-url'
|
||||
import { PubsubClient } from '../datalayer/pubsub'
|
||||
import { ArticleSavingRequestStatus, Page } from '../elastic/types'
|
||||
|
|
@ -20,6 +24,10 @@ export type SaveEmailInput = {
|
|||
unsubHttpUrl?: string
|
||||
}
|
||||
|
||||
const isStubUrl = (url: string): boolean => {
|
||||
return url.startsWith(FAKE_URL_PREFIX)
|
||||
}
|
||||
|
||||
export const saveEmail = async (
|
||||
ctx: SaveContext,
|
||||
input: SaveEmailInput
|
||||
|
|
@ -37,7 +45,7 @@ export const saveEmail = async (
|
|||
)
|
||||
const content = parseResult.parsedContent?.content || input.originalContent
|
||||
const slug = generateSlug(input.title)
|
||||
const metadata = await parseUrlMetadata(url)
|
||||
const metadata = isStubUrl(url) ? undefined : await parseUrlMetadata(url)
|
||||
|
||||
const articleToSave: Page = {
|
||||
id: '',
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ const DOM_PURIFY_CONFIG = {
|
|||
}
|
||||
const ARTICLE_PREFIX = 'omnivore:'
|
||||
|
||||
export const FAKE_URL_PREFIX = 'https://omnivore.app/no_url?q='
|
||||
|
||||
interface ContentHandler {
|
||||
shouldPrehandle: (url: URL, dom: Document) => boolean
|
||||
prehandle: (url: URL, document: Document) => Promise<Document>
|
||||
|
|
@ -562,7 +564,7 @@ export const isProbablyArticle = async (
|
|||
return !!user || subject.includes(ARTICLE_PREFIX)
|
||||
}
|
||||
|
||||
export const generateUniqueUrl = () => 'https://omnivore.app/no_url?q=' + uuid()
|
||||
export const generateUniqueUrl = () => FAKE_URL_PREFIX + uuid()
|
||||
|
||||
export const getTitleFromEmailSubject = (subject: string) => {
|
||||
const title = subject.replace(ARTICLE_PREFIX, '')
|
||||
|
|
|
|||
Loading…
Reference in a new issue