From 99f2ffd6d591398a4baef347306d25371b381793 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 10 Jun 2024 17:03:10 -0700 Subject: [PATCH] Update webhook.ts --- apps/api/src/services/webhook.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/api/src/services/webhook.ts b/apps/api/src/services/webhook.ts index eca7d09f..1f8d6471 100644 --- a/apps/api/src/services/webhook.ts +++ b/apps/api/src/services/webhook.ts @@ -3,15 +3,17 @@ import { supabase_service } from "./supabase"; export const callWebhook = async (teamId: string, data: any) => { try { const selfHostedUrl = process.env.SELF_HOSTED_WEBHOOK_URL; + const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true'; let webhookUrl = selfHostedUrl; - if (!selfHostedUrl) { + // Only fetch the webhook URL from the database if the self-hosted webhook URL is not set + // and the USE_DB_AUTHENTICATION environment variable is set to true + if (!selfHostedUrl && useDbAuthentication) { const { data: webhooksData, error } = await supabase_service .from("webhooks") .select("url") .eq("team_id", teamId) .limit(1); - if (error) { console.error( `Error fetching webhook URL for team ID: ${teamId}`,