Fix #158 – @trigger.dev/typeform: Check that webhook has a matching url
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/typeform": patch
|
||||
---
|
||||
|
||||
Create a new webhook if the existing webhook url doesn't match
|
||||
@@ -180,12 +180,35 @@ export function createWebhookEventSource(
|
||||
};
|
||||
}
|
||||
|
||||
const createWebhook = async () => {
|
||||
const newWebhookData = await io.integration.createWebhook(
|
||||
"create-webhook",
|
||||
{
|
||||
uid: params.uid,
|
||||
tag: params.tag,
|
||||
url: httpSource.url,
|
||||
enabled: true,
|
||||
secret: httpSource.secret,
|
||||
verifySSL: true,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data: newWebhookData,
|
||||
registeredEvents: ["all"],
|
||||
};
|
||||
};
|
||||
|
||||
try {
|
||||
const existingWebhook = await io.integration.getWebhook(
|
||||
"get-webhook",
|
||||
params
|
||||
);
|
||||
|
||||
if (existingWebhook.url !== httpSource.url) {
|
||||
return createWebhook();
|
||||
}
|
||||
|
||||
if (existingWebhook.enabled) {
|
||||
return {
|
||||
data: existingWebhook,
|
||||
@@ -210,22 +233,7 @@ export function createWebhookEventSource(
|
||||
registeredEvents: ["all"],
|
||||
};
|
||||
} catch (error) {
|
||||
const newWebhookData = await io.integration.createWebhook(
|
||||
"create-webhook",
|
||||
{
|
||||
uid: params.uid,
|
||||
tag: params.tag,
|
||||
url: httpSource.url,
|
||||
enabled: true,
|
||||
secret: httpSource.secret,
|
||||
verifySSL: true,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
data: newWebhookData,
|
||||
registeredEvents: ["all"],
|
||||
};
|
||||
return createWebhook();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user