feat: start a cloud task to set thumbnail and pre-cache all the images in the content

This commit is contained in:
Hongbo Wu
2023-06-06 11:56:31 +08:00
parent e2315b5662
commit 0c3fa2cdd4
4 changed files with 35 additions and 11 deletions

View File

@ -22,7 +22,7 @@ const logger = buildLogger('app.dispatch')
const client = new CloudTasksClient()
const createHttpTaskWithToken = async ({
project,
project = process.env.GOOGLE_CLOUD_PROJECT,
queue = env.queue.name,
location = env.queue.location,
taskHandlerUrl = env.queue.contentFetchUrl,
@ -32,7 +32,7 @@ const createHttpTaskWithToken = async ({
scheduleTime,
requestHeaders,
}: {
project: string
project?: string
queue?: string
location?: string
taskHandlerUrl?: string
@ -42,12 +42,18 @@ const createHttpTaskWithToken = async ({
scheduleTime?: number
requestHeaders?: Record<string, string>
}): Promise<
[
protos.google.cloud.tasks.v2.ITask,
protos.google.cloud.tasks.v2.ICreateTaskRequest | undefined,
unknown | undefined
]
| [
protos.google.cloud.tasks.v2.ITask,
protos.google.cloud.tasks.v2.ICreateTaskRequest | undefined,
unknown | undefined
]
| null
> => {
// If there is no Google Cloud Project Id exposed, it means that we are in local environment
if (env.dev.isLocal || !project) {
return null
}
// Construct the fully qualified queue name.
priority === 'low' && (queue = `${queue}-low`)
@ -458,7 +464,6 @@ export const enqueueRecommendation = async (
}
export const enqueueImportFromIntegration = async (
userId: string,
integrationId: string,
authToken: string
): Promise<string> => {