mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(Webflow Trigger Node): Reduce chance of webhook duplication and add credential test (#3594)
* upstream merge * ⚡ additional check for webhook, credentials update * 🔥 Remove unnecessary condition * ⚡ Change credential injection to generic type * 👕 Fix linting issue Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
@@ -208,18 +208,22 @@ export class WebflowTrigger implements INodeType {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const siteId = this.getNodeParameter('site') as string;
|
||||
if (webhookData.webhookId === undefined) {
|
||||
return false;
|
||||
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
const registeredWebhooks = await webflowApiRequest.call(this, 'GET', `/sites/${siteId}/webhooks`) as IDataObject[];
|
||||
|
||||
for (const webhook of registeredWebhooks) {
|
||||
if (webhook.url === webhookUrl && webhook.triggerType === event) {
|
||||
webhookData.webhookId = webhook._id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const endpoint = `/sites/${siteId}/webhooks/${webhookData.webhookId}`;
|
||||
try {
|
||||
await webflowApiRequest.call(this, 'GET', endpoint);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
|
||||
Reference in New Issue
Block a user