From 431e64e752cc697a5c3afc57b4413f42ef8196a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B3ricz=20Gerg=C5=91?= Date: Thu, 14 Nov 2024 22:39:41 +0100 Subject: [PATCH] fix(batch/scrape/webhook): add batch_scrape.started --- apps/api/src/controllers/v1/batch-scrape.ts | 5 +++++ apps/api/src/types.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/api/src/controllers/v1/batch-scrape.ts b/apps/api/src/controllers/v1/batch-scrape.ts index 9fd5cc50..3830b1fe 100644 --- a/apps/api/src/controllers/v1/batch-scrape.ts +++ b/apps/api/src/controllers/v1/batch-scrape.ts @@ -16,6 +16,7 @@ import { logCrawl } from "../../services/logging/crawl_log"; import { getScrapeQueue } from "../../services/queue-service"; import { getJobPriority } from "../../lib/job-priority"; import { addScrapeJobs } from "../../services/queue-jobs"; +import { callWebhook } from "../../services/webhook"; export async function batchScrapeController( req: RequestWithAuth<{}, CrawlResponse, BatchScrapeRequest>, @@ -86,6 +87,10 @@ export async function batchScrapeController( ); await addScrapeJobs(jobs); + if(req.body.webhook) { + await callWebhook(req.auth.team_id, id, null, req.body.webhook, true, "batch_scrape.started"); + } + const protocol = process.env.ENV === "local" ? req.protocol : "https"; return res.status(200).json({ diff --git a/apps/api/src/types.ts b/apps/api/src/types.ts index d7821407..cc04ca18 100644 --- a/apps/api/src/types.ts +++ b/apps/api/src/types.ts @@ -166,4 +166,4 @@ export type PlanType = | ""; -export type WebhookEventType = "crawl.page" | "batch_scrape.page" | "crawl.started" | "crawl.completed" | "batch_scrape.completed" | "crawl.failed"; \ No newline at end of file +export type WebhookEventType = "crawl.page" | "batch_scrape.page" | "crawl.started" | "batch_scrape.started" | "crawl.completed" | "batch_scrape.completed" | "crawl.failed"; \ No newline at end of file