From 34798f39f03223c3eec55f5dcbb6d0df7cb41df3 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 16 Oct 2023 11:25:37 +0800 Subject: [PATCH 1/2] Disable JSONLD fetching which can be quite slow --- packages/api/src/utils/parser.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/api/src/utils/parser.ts b/packages/api/src/utils/parser.ts index f8ca6ffa2..ae047ef82 100644 --- a/packages/api/src/utils/parser.ts +++ b/packages/api/src/utils/parser.ts @@ -332,18 +332,13 @@ export const parsePreparedContent = async ( DOMPurify.addHook('uponSanitizeElement', domPurifySanitizeHook) const clean = DOMPurify.sanitize(article?.content || '', DOM_PURIFY_CONFIG) - const jsonLdLinkMetadata = (async () => { - return getJSONLdLinkMetadata(dom) - })() - Object.assign(article || {}, { content: clean, - title: article?.title || (await jsonLdLinkMetadata).title, - previewImage: - article?.previewImage || (await jsonLdLinkMetadata).previewImage, - siteName: article?.siteName || (await jsonLdLinkMetadata).siteName, + title: article?.title, + previewImage: article?.previewImage, + siteName: article?.siteName, siteIcon: article?.siteIcon, - byline: article?.byline || (await jsonLdLinkMetadata).byline, + byline: article?.byline, language: article?.language, }) logRecord.parseSuccess = true From 4f86f05aac8ff02186ed40dffabbe28ce91856fc Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 16 Oct 2023 11:39:03 +0800 Subject: [PATCH 2/2] Remove JSONLD test --- packages/api/test/utils/parser.test.ts | 50 +++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/api/test/utils/parser.test.ts b/packages/api/test/utils/parser.test.ts index 4dfa720d0..939a1d17c 100644 --- a/packages/api/test/utils/parser.test.ts +++ b/packages/api/test/utils/parser.test.ts @@ -78,32 +78,32 @@ describe('parsePreparedContent', () => { }) }) -describe('parsePreparedContent', () => { - nock('https://oembeddata').get('/').reply(200, { - version: '1.0', - provider_name: 'Hippocratic Adventures', - provider_url: 'https://www.hippocraticadventures.com', - title: - 'The Ultimate Guide to Practicing Medicine in Singapore – Part 2', - }) +// describe('parsePreparedContent', () => { +// nock('https://oembeddata').get('/').reply(200, { +// version: '1.0', +// provider_name: 'Hippocratic Adventures', +// provider_url: 'https://www.hippocraticadventures.com', +// title: +// 'The Ultimate Guide to Practicing Medicine in Singapore – Part 2', +// }) - it('gets metadata from external JSONLD if available', async () => { - const html = ` - - - - body - ` - const result = await parsePreparedContent('https://blog.omnivore.app/', { - document: html, - pageInfo: {}, - }) - expect(result.parsedContent?.title).to.equal( - 'The Ultimate Guide to Practicing Medicine in Singapore – Part 2' - ) - }) -}) +// it('gets metadata from external JSONLD if available', async () => { +// const html = ` +// +// +// +// body +// ` +// const result = await parsePreparedContent('https://blog.omnivore.app/', { +// document: html, +// pageInfo: {}, +// }) +// expect(result.parsedContent?.title).to.equal( +// 'The Ultimate Guide to Practicing Medicine in Singapore – Part 2' +// ) +// }) +// }) describe('isProbablyArticle', () => { let user: User