Skip to content

Commit

Permalink
fix(Venafi TLS Protect Cloud Trigger Node): Handle new webhook payloa…
Browse files Browse the repository at this point in the history
…d format (#8326)
  • Loading branch information
RicardoE105 authored Jan 15, 2024
1 parent 6b92d49 commit 057d7d0
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ export class VenafiTlsProtectCloudTrigger implements INodeType {
for (const connector of connectors) {
const {
id,
status,
properties: {
target: {
connection: { url },
},
},
} = connector;

if (url === webhookUrl) {
if (url === webhookUrl && status === 'Active') {
await venafiApiRequest.call(this, 'DELETE', `/v1/connectors/${id}`);
return false;
}
Expand Down Expand Up @@ -172,10 +173,10 @@ export class VenafiTlsProtectCloudTrigger implements INodeType {
};

async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const bodyData = this.getBodyData() as { message: string; eventName: string };
const { events } = this.getBodyData() as { events: [{ message: string; eventName: string }] };
const triggerOn = this.getNodeParameter('triggerOn') as string;

if (Object.keys(bodyData).length === 1 && bodyData.message) {
if (Array.isArray(events) && events[0]?.message?.includes('TESTING CONNECTION...')) {
// Is a create webhook confirmation request
const res = this.getResponseObject();
res.status(200).end();
Expand All @@ -184,10 +185,10 @@ export class VenafiTlsProtectCloudTrigger implements INodeType {
};
}

if (!triggerOn.includes('*') && !triggerOn.includes(bodyData.eventName)) return {};
if (!triggerOn.includes('*') && !triggerOn.includes(events[0]?.eventName)) return {};

return {
workflowData: [this.helpers.returnJsonArray(bodyData)],
workflowData: [this.helpers.returnJsonArray(events)],
};
}
}

0 comments on commit 057d7d0

Please sign in to comment.