Move checks to have the PDF check

This commit is contained in:
Jackson Harper
2024-01-21 13:19:50 +08:00
parent 9abd0a59da
commit eefceeb1ef

View File

@ -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.', {