send labels in the page_created events
This commit is contained in:
@ -3,7 +3,7 @@ import { User } from '../entity/user'
|
||||
import { homePageURL } from '../env'
|
||||
import { SaveErrorCode, SaveFileInput, SaveResult } from '../generated/graphql'
|
||||
import { getStorageFileDetails } from '../utils/uploads'
|
||||
import { createAndSaveLabelsInLibraryItem } from './labels'
|
||||
import { createAndAddLabelsToLibraryItem } from './labels'
|
||||
import { updateLibraryItem } from './library_item'
|
||||
import { findUploadFileById, setFileUploadComplete } from './upload_file'
|
||||
|
||||
@ -39,12 +39,13 @@ export const saveFile = async (
|
||||
folder: input.folder || undefined,
|
||||
savedAt: input.savedAt ? new Date(input.savedAt) : undefined,
|
||||
publishedAt: input.publishedAt ? new Date(input.publishedAt) : undefined,
|
||||
labelNames: input.labels?.map((label) => label.name) || undefined,
|
||||
},
|
||||
user.id
|
||||
)
|
||||
|
||||
// add labels to item
|
||||
await createAndSaveLabelsInLibraryItem(
|
||||
await createAndAddLabelsToLibraryItem(
|
||||
input.clientRequestId,
|
||||
user.id,
|
||||
input.labels,
|
||||
|
||||
@ -134,6 +134,7 @@ export const savePage = async (
|
||||
feedContent: input.feedContent,
|
||||
dir: parseResult.parsedContent?.dir,
|
||||
preparedDocument,
|
||||
labelNames: input.labels?.map((label) => label.name),
|
||||
})
|
||||
const isImported =
|
||||
input.source === 'csv-importer' || input.source === 'pocket'
|
||||
@ -213,6 +214,7 @@ export const parsedContentToLibraryItem = ({
|
||||
folder,
|
||||
feedContent,
|
||||
dir,
|
||||
labelNames,
|
||||
}: {
|
||||
url: string
|
||||
userId: string
|
||||
@ -234,6 +236,7 @@ export const parsedContentToLibraryItem = ({
|
||||
folder?: string | null
|
||||
feedContent?: string | null
|
||||
dir?: string | null
|
||||
labelNames?: string[]
|
||||
}): DeepPartial<LibraryItem> & { originalUrl: string } => {
|
||||
logger.info('save_page', { url, state, itemId })
|
||||
return {
|
||||
@ -281,5 +284,6 @@ export const parsedContentToLibraryItem = ({
|
||||
dir?.toLowerCase() === 'rtl'
|
||||
? DirectionalityType.RTL
|
||||
: DirectionalityType.LTR, // default to LTR
|
||||
labelNames,
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import {
|
||||
ArticleSavingRequestStatus,
|
||||
CreateLabelInput,
|
||||
} from '../generated/graphql'
|
||||
import { AISummarizeJobData, AI_SUMMARIZE_JOB_NAME } from '../jobs/ai-summarize'
|
||||
import { BulkActionData, BULK_ACTION_JOB_NAME } from '../jobs/bulk_action'
|
||||
import { CallWebhookJobData, CALL_WEBHOOK_JOB_NAME } from '../jobs/call_webhook'
|
||||
import { THUMBNAIL_JOB } from '../jobs/find_thumbnail'
|
||||
@ -23,6 +24,12 @@ import {
|
||||
ExportItemJobData,
|
||||
EXPORT_ITEM_JOB_NAME,
|
||||
} from '../jobs/integration/export_item'
|
||||
import {
|
||||
ProcessYouTubeTranscriptJobData,
|
||||
ProcessYouTubeVideoJobData,
|
||||
PROCESS_YOUTUBE_TRANSCRIPT_JOB_NAME,
|
||||
PROCESS_YOUTUBE_VIDEO_JOB_NAME,
|
||||
} from '../jobs/process-youtube-video'
|
||||
import {
|
||||
queueRSSRefreshFeedJob,
|
||||
REFRESH_ALL_FEEDS_JOB_NAME,
|
||||
@ -44,13 +51,6 @@ import { CreateTaskError } from './errors'
|
||||
import { stringToHash } from './helpers'
|
||||
import { logger } from './logger'
|
||||
import View = google.cloud.tasks.v2.Task.View
|
||||
import { AISummarizeJobData, AI_SUMMARIZE_JOB_NAME } from '../jobs/ai-summarize'
|
||||
import {
|
||||
PROCESS_YOUTUBE_TRANSCRIPT_JOB_NAME,
|
||||
PROCESS_YOUTUBE_VIDEO_JOB_NAME,
|
||||
ProcessYouTubeTranscriptJobData,
|
||||
ProcessYouTubeVideoJobData,
|
||||
} from '../jobs/process-youtube-video'
|
||||
|
||||
// Instantiates a client.
|
||||
const client = new CloudTasksClient()
|
||||
@ -132,9 +132,18 @@ const createHttpTaskWithToken = async ({
|
||||
> => {
|
||||
// If there is no Google Cloud Project Id exposed, it means that we are in local environment
|
||||
if (env.dev.isLocal || !project) {
|
||||
logger.error(
|
||||
'error: attempting to create a cloud task but not running in google cloud.'
|
||||
)
|
||||
setTimeout(() => {
|
||||
axios
|
||||
.post(taskHandlerUrl, payload, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...requestHeaders,
|
||||
},
|
||||
})
|
||||
.catch((error) => {
|
||||
logError(error)
|
||||
})
|
||||
})
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user