From 52399b37027d499ca0cb8faab22a799b83a88a80 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 3 Mar 2023 09:03:43 +0800 Subject: [PATCH] Add state and labels to the cloud task --- packages/import-handler/src/index.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/import-handler/src/index.ts b/packages/import-handler/src/index.ts index 209edd852..d1cfd9ebb 100644 --- a/packages/import-handler/src/index.ts +++ b/packages/import-handler/src/index.ts @@ -73,13 +73,17 @@ const shouldHandle = (data: StorageEvent) => { const importURL = async ( userId: string, url: URL, - source: string + source: string, + state?: RetrievedDataState, + labels?: string[] ): Promise => { return createCloudTask(CONTENT_FETCH_URL, { userId, source, url: url.toString(), saveRequestId: uuid(), + state, + labels, }) } @@ -129,10 +133,21 @@ const handlerForFile = (name: string): importHandlerFunc | undefined => { return undefined } -const urlHandler = async (ctx: ImportContext, url: URL): Promise => { +const urlHandler = async ( + ctx: ImportContext, + url: URL, + state?: RetrievedDataState, + labels?: string[] +): Promise => { try { // Imports are stored in the format imports//-.csv - const result = await importURL(ctx.userId, url, 'csv-importer') + const result = await importURL( + ctx.userId, + url, + 'csv-importer', + state, + labels + ) if (result) { ctx.countImported += 1 }