mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-05 19:36:07 +08:00
feat: webhooks config on v1
This commit is contained in:
parent
c8e0bb93ea
commit
dc189e1e9d
@ -218,8 +218,8 @@ async function processJob(job: Job, token: string) {
|
|||||||
docs,
|
docs,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (job.data.mode === "crawl") {
|
if (job.data.webhook && job.data.mode !== "crawl") {
|
||||||
await callWebhook(job.data.team_id, job.id as string, data, job.data.webhook, job.data.v1);
|
await callWebhook(job.data.team_id, job.data.crawl_id, data, job.data.webhook, job.data.v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job.data.crawl_id) {
|
if (job.data.crawl_id) {
|
||||||
@ -342,8 +342,6 @@ async function processJob(job: Job, token: string) {
|
|||||||
error: message /* etc... */,
|
error: message /* etc... */,
|
||||||
docs: fullDocs,
|
docs: fullDocs,
|
||||||
};
|
};
|
||||||
|
|
||||||
await callWebhook(job.data.team_id, job.data.crawl_id, data, job.data.webhook, job.data.v1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,10 +384,6 @@ async function processJob(job: Job, token: string) {
|
|||||||
"Something went wrong... Contact help@mendable.ai or try again." /* etc... */,
|
"Something went wrong... Contact help@mendable.ai or try again." /* etc... */,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (job.data.mode === "crawl" || job.data.crawl_id) {
|
|
||||||
await callWebhook(job.data.team_id, job.data.crawl_id ?? job.id as string, data, job.data.webhook, job.data.v1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (job.data.crawl_id) {
|
if (job.data.crawl_id) {
|
||||||
await logJob({
|
await logJob({
|
||||||
job_id: job.id as string,
|
job_id: job.id as string,
|
||||||
|
@ -2,9 +2,9 @@ import { legacyDocumentConverter } from "../../src/controllers/v1/types";
|
|||||||
import { Logger } from "../../src/lib/logger";
|
import { Logger } from "../../src/lib/logger";
|
||||||
import { supabase_service } from "./supabase";
|
import { supabase_service } from "./supabase";
|
||||||
|
|
||||||
export const callWebhook = async (teamId: string, jobId: string, data: any, specified?: string, v1 = false) => {
|
export const callWebhook = async (teamId: string, id: string, data: any, specified?: string, v1 = false) => {
|
||||||
try {
|
try {
|
||||||
const selfHostedUrl = process.env.SELF_HOSTED_WEBHOOK_URL?.replace("{{JOB_ID}}", jobId);
|
const selfHostedUrl = process.env.SELF_HOSTED_WEBHOOK_URL?.replace("{{JOB_ID}}", id);
|
||||||
const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';
|
const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';
|
||||||
let webhookUrl = specified ?? selfHostedUrl;
|
let webhookUrl = specified ?? selfHostedUrl;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ export const callWebhook = async (teamId: string, jobId: string, data: any, spec
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
success: data.success,
|
success: data.success,
|
||||||
jobId: jobId,
|
id: id,
|
||||||
data: dataToSend,
|
data: dataToSend,
|
||||||
error: data.error || undefined,
|
error: data.error || undefined,
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user