mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
fix: when source is rss-feed or csv-import, do not parse items in the backend
This commit is contained in:
parent
5d87f07f0f
commit
bbc46c6389
2 changed files with 31 additions and 5 deletions
|
|
@ -36,6 +36,7 @@ const FORCE_PUPPETEER_URLS = [
|
|||
TWEET_URL_REGEX,
|
||||
/^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/,
|
||||
]
|
||||
const ALREADY_PARSED_SOURCES = ['puppeteer-parse', 'csv-importer', 'rss-feeder']
|
||||
|
||||
const createSlug = (url: string, title?: Maybe<string> | undefined) => {
|
||||
const { pathname } = new URL(url)
|
||||
|
|
@ -52,7 +53,7 @@ const createSlug = (url: string, title?: Maybe<string> | undefined) => {
|
|||
|
||||
const shouldParseInBackend = (input: SavePageInput): boolean => {
|
||||
return (
|
||||
input.source !== 'puppeteer-parse' &&
|
||||
ALREADY_PARSED_SOURCES.indexOf(input.source) === -1 &&
|
||||
FORCE_PUPPETEER_URLS.some((regex) => regex.test(input.url))
|
||||
)
|
||||
}
|
||||
|
|
@ -99,7 +100,7 @@ export const savePage = async (
|
|||
await createPageSaveRequest({
|
||||
userId: user.id,
|
||||
url: itemToSave.originalUrl,
|
||||
articleSavingRequestId: clientRequestId,
|
||||
articleSavingRequestId: clientRequestId || undefined,
|
||||
state: input.state || undefined,
|
||||
labels: input.labels || undefined,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -185,15 +185,17 @@ const savePageQuery = (
|
|||
title: string,
|
||||
originalContent: string,
|
||||
state: ArticleSavingRequestStatus | null = null,
|
||||
labels: string[] | null = null
|
||||
labels: string[] | null = null,
|
||||
clientRequestId = generateFakeUuid(),
|
||||
source = 'puppeteer-parse'
|
||||
) => {
|
||||
return `
|
||||
mutation {
|
||||
savePage(
|
||||
input: {
|
||||
url: "${url}",
|
||||
source: "test",
|
||||
clientRequestId: "${generateFakeUuid()}",
|
||||
source: "${source}",
|
||||
clientRequestId: "${clientRequestId}",
|
||||
title: "${title}",
|
||||
originalContent: "${originalContent}"
|
||||
state: ${state}
|
||||
|
|
@ -605,6 +607,29 @@ describe('Article API', () => {
|
|||
expect(savedItem?.labels?.map((l) => l.name)).to.eql(labels)
|
||||
})
|
||||
})
|
||||
|
||||
context('when the source is rss-feeder', () => {
|
||||
const source = 'rss-feeder'
|
||||
const stub = sinon.stub(createTask, 'enqueueParseRequest')
|
||||
|
||||
before(() => {
|
||||
url = 'https://blog.omnivore.app/new-url-3'
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await deleteLibraryItemByUrl(url, user.id)
|
||||
sinon.restore()
|
||||
})
|
||||
|
||||
it('does not parse in the backend', async () => {
|
||||
await graphqlRequest(
|
||||
savePageQuery(url, title, originalContent, null, null, '', source),
|
||||
authToken
|
||||
).expect(200)
|
||||
|
||||
expect(stub).not.to.have.been.called
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('SaveUrl', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue