update create article api

This commit is contained in:
Hongbo Wu
2024-02-06 15:28:50 +08:00
parent 250d9089b3
commit a37bfab348
2 changed files with 25 additions and 71 deletions

View File

@ -340,29 +340,12 @@ export const createArticleResolver = authorized<
}
}
let libraryItemToReturn: LibraryItem
const existingLibraryItem = await findLibraryItemByUrl(
libraryItemToSave.originalUrl,
uid
// create new item in database
const libraryItemToReturn = await createOrUpdateLibraryItem(
libraryItemToSave,
uid,
pubsub
)
articleSavingRequestId = existingLibraryItem?.id || articleSavingRequestId
if (articleSavingRequestId) {
// update existing item's state from processing to succeeded
libraryItemToReturn = await updateLibraryItem(
articleSavingRequestId,
libraryItemToSave as QueryDeepPartialEntity<LibraryItem>,
uid,
pubsub
)
} else {
// create new item in database
libraryItemToReturn = await createOrUpdateLibraryItem(
libraryItemToSave,
uid,
pubsub
)
}
await createAndSaveLabelsInLibraryItem(
libraryItemToReturn.id,
@ -371,14 +354,6 @@ export const createArticleResolver = authorized<
rssFeedUrl
)
log.info(
'item created in database',
libraryItemToReturn.id,
libraryItemToReturn.originalUrl,
libraryItemToReturn.slug,
libraryItemToReturn.title
)
return {
user,
created: true,