feat(crawl): webhook
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { Logger } from "../../src/lib/logger";
|
||||
import { supabase_service } from "./supabase";
|
||||
|
||||
export const callWebhook = async (teamId: string, jobId: string,data: any) => {
|
||||
export const callWebhook = async (teamId: string, jobId: string, data: any, specified?: string) => {
|
||||
try {
|
||||
const selfHostedUrl = process.env.SELF_HOSTED_WEBHOOK_URL?.replace("{{JOB_ID}}", jobId);
|
||||
const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';
|
||||
let webhookUrl = selfHostedUrl;
|
||||
let webhookUrl = specified ?? selfHostedUrl;
|
||||
|
||||
// Only fetch the webhook URL from the database if the self-hosted webhook URL is not set
|
||||
// Only fetch the webhook URL from the database if the self-hosted webhook URL and specified webhook are not set
|
||||
// and the USE_DB_AUTHENTICATION environment variable is set to true
|
||||
if (!selfHostedUrl && useDbAuthentication) {
|
||||
if (!webhookUrl && useDbAuthentication) {
|
||||
const { data: webhooksData, error } = await supabase_service
|
||||
.from("webhooks")
|
||||
.select("url")
|
||||
|
||||
Reference in New Issue
Block a user