From eefceeb1ef3758ad3eaa61b41310ee282b4fcb0d Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Sun, 21 Jan 2024 13:19:50 +0800 Subject: [PATCH] Move checks to have the PDF check --- packages/api/src/jobs/save_page.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/api/src/jobs/save_page.ts b/packages/api/src/jobs/save_page.ts index cdeddc969..7eacbf3d5 100644 --- a/packages/api/src/jobs/save_page.ts +++ b/packages/api/src/jobs/save_page.ts @@ -309,12 +309,6 @@ export const savePageJob = async (data: Data, attemptsMade: number) => { const { title, content, contentType, readabilityResult } = await getCachedFetchResult(url) - if (!title || !content || !contentType || !readabilityResult) { - throw new Error( - 'Invalid SavePage job, fetch result missing required data' - ) - } - // for pdf content, we need to upload the pdf if (contentType === 'application/pdf') { const uploadFileId = await uploadPdf(url, userId, articleSavingRequestId) @@ -339,6 +333,12 @@ export const savePageJob = async (data: Data, attemptsMade: number) => { return true } + if (!title || !content || !contentType || !readabilityResult) { + throw new Error( + 'Invalid SavePage job, fetch result missing required data' + ) + } + const user = await userRepository.findById(userId) if (!user) { logger.error('Unable to save job, user can not be found.', {