Skip to content

Commit

Permalink
Merge pull request mendableai#262 from mendableai/nsc/webhook-self-ho…
Browse files Browse the repository at this point in the history
…st-fix

Only fetch webhook from db if self host webhook not set and using db auth
  • Loading branch information
nickscamara authored Jun 11, 2024
2 parents c08db83 + 99f2ffd commit 45dee63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/api/src/services/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down

0 comments on commit 45dee63

Please sign in to comment.