This commit is contained in:
Kartik Saini
2025-02-12 17:48:16 +05:30
parent cb120c56f6
commit 1f80f8f396
2 changed files with 3 additions and 19 deletions
@@ -114,9 +114,7 @@ export const AddWebhookModal = ({ environmentId, surveys, open, setOpen }: AddWe
}
const DISCORD_WEBHOOK_URL_PATTERN = /^https:\/\/discord\.com\/api\/webhooks\/\d+\/.+$/;
const webhookUrl = new URL(testEndpointInput);
const isDiscordWebhook = DISCORD_WEBHOOK_URL_PATTERN.test(webhookUrl.toString());
if (isDiscordWebhook) {
@@ -157,25 +157,11 @@ export const testEndpoint = async (url: string): Promise<boolean> => {
);
}
const payload = isDiscordWebhook
? {
content: "🔔 Test notification from Formbricks",
embeds: [
{
title: "Webhook Test",
description: "Ping! This is a test notification from Formbricks.",
color: 0x00ff00,
},
],
}
: {
event: "testEndpoint",
message: "Ping! This is a test notification from Formbricks.",
};
const response = await fetch(url, {
method: "POST",
body: JSON.stringify(payload),
body: JSON.stringify({
event: "testEndpoint",
}),
headers: {
"Content-Type": "application/json",
},