mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #3422 from omnivore-app/fix/no-content
set the state to failed if content is not fetched
This commit is contained in:
commit
9f1a17853a
1 changed files with 12 additions and 13 deletions
|
|
@ -114,7 +114,7 @@ const getUploadIdAndSignedUrl = async (
|
|||
}`,
|
||||
variables: {
|
||||
input: {
|
||||
url,
|
||||
url: encodeURI(url),
|
||||
contentType: 'application/pdf',
|
||||
clientRequestId: articleSavingRequestId,
|
||||
},
|
||||
|
|
@ -279,7 +279,6 @@ export const savePageJob = async (data: Data, attemptsMade: number) => {
|
|||
const {
|
||||
userId,
|
||||
articleSavingRequestId,
|
||||
state,
|
||||
labels,
|
||||
source,
|
||||
folder,
|
||||
|
|
@ -289,24 +288,23 @@ export const savePageJob = async (data: Data, attemptsMade: number) => {
|
|||
taskId,
|
||||
url,
|
||||
} = data
|
||||
let isImported, isSaved
|
||||
let isImported,
|
||||
isSaved,
|
||||
state = data.state
|
||||
|
||||
try {
|
||||
console.log(`savePageJob: ${userId} ${url}`)
|
||||
|
||||
// get the fetch result from cache
|
||||
const { title, content, contentType, readabilityResult } =
|
||||
await getCachedFetchResult(url)
|
||||
const fetchedResult = await getCachedFetchResult(url)
|
||||
const { title, contentType, readabilityResult } = fetchedResult
|
||||
let content = fetchedResult.content
|
||||
|
||||
// for pdf content, we need to upload the pdf
|
||||
if (contentType === 'application/pdf') {
|
||||
const encodedUrl = encodeURI(url)
|
||||
|
||||
const uploadFileId = await uploadPdf(
|
||||
encodedUrl,
|
||||
userId,
|
||||
articleSavingRequestId
|
||||
)
|
||||
const uploadFileId = await uploadPdf(url, userId, articleSavingRequestId)
|
||||
const uploadedPdf = await sendCreateArticleMutation(userId, {
|
||||
url: encodedUrl,
|
||||
articleSavingRequestId,
|
||||
|
|
@ -329,9 +327,10 @@ export const savePageJob = async (data: Data, attemptsMade: number) => {
|
|||
}
|
||||
|
||||
if (!content) {
|
||||
throw new Error(
|
||||
'Invalid SavePage job, fetch result missing required data'
|
||||
)
|
||||
console.log('content is not fetched', url)
|
||||
// set the state to failed if we don't have content
|
||||
content = 'Failed to fetch content'
|
||||
state = ArticleSavingRequestStatus.Failed
|
||||
}
|
||||
|
||||
const user = await userRepository.findById(userId)
|
||||
|
|
|
|||
Loading…
Reference in a new issue