From 04cf86369d7f3134424bffd82a2c871ce0d05afb Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Thu, 8 Oct 2020 10:39:13 -0400 Subject: [PATCH] :bug: Fix issue Pipedrive-Trigger bug #1018 (#1021) --- .../nodes/Pipedrive/PipedriveTrigger.node.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts b/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts index 99f10d68de..ea00bb209d 100644 --- a/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts @@ -187,12 +187,13 @@ export class PipedriveTrigger implements INodeType { webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { + const webhookUrl = this.getNodeWebhookUrl('default'); + const webhookData = this.getWorkflowStaticData('node'); - if (webhookData.webhookId === undefined) { - // No webhook id is set so no webhook can exist - return false; - } + const eventAction = this.getNodeParameter('action') as string; + + const eventObject = this.getNodeParameter('object') as string; // Webhook got created before so check if it still exists const endpoint = `/webhooks`; @@ -204,8 +205,11 @@ export class PipedriveTrigger implements INodeType { } for (const existingData of responseData.data) { - if (existingData.id === webhookData.webhookId) { + if (existingData.subscription_url === webhookUrl + && existingData.event_action === eventAction + && existingData.event_object === eventObject) { // The webhook exists already + webhookData.webhookId = existingData.id; return true; } }