mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -11,13 +8,9 @@ import {
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
stravaApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { stravaApiRequest } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
randomBytes,
|
||||
} from 'crypto';
|
||||
import { randomBytes } from 'crypto';
|
||||
|
||||
export class StravaTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -103,7 +96,8 @@ export class StravaTrigger implements INodeType {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description: 'By default the webhook-data only contain the Object ID. If this option gets activated, it will resolve the data automatically.',
|
||||
description:
|
||||
'By default the webhook-data only contain the Object ID. If this option gets activated, it will resolve the data automatically.',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
@@ -118,7 +112,8 @@ export class StravaTrigger implements INodeType {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description: 'Strava allows just one subscription at all times. If you want to delete the current subscription to make room for a new subcription with the current parameters, set this parameter to true. Keep in mind this is a destructive operation.',
|
||||
description:
|
||||
'Strava allows just one subscription at all times. If you want to delete the current subscription to make room for a new subcription with the current parameters, set this parameter to true. Keep in mind this is a destructive operation.',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -170,18 +165,32 @@ export class StravaTrigger implements INodeType {
|
||||
if (error.resource === 'PushSubscription' && error.code === 'already exists') {
|
||||
const options = this.getNodeParameter('options') as IDataObject;
|
||||
//get the current subscription
|
||||
const webhooks = await stravaApiRequest.call(this, 'GET', `/push_subscriptions`, {});
|
||||
const webhooks = await stravaApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/push_subscriptions`,
|
||||
{},
|
||||
);
|
||||
|
||||
if (options.deleteIfExist) {
|
||||
// delete the subscription
|
||||
await stravaApiRequest.call(this, 'DELETE', `/push_subscriptions/${webhooks[0].id}`);
|
||||
await stravaApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/push_subscriptions/${webhooks[0].id}`,
|
||||
);
|
||||
// now there is room create a subscription with the n8n data
|
||||
const body = {
|
||||
callback_url: webhookUrl,
|
||||
verify_token: randomBytes(20).toString('hex') as string,
|
||||
};
|
||||
|
||||
responseData = await stravaApiRequest.call(this, 'POST', `/push_subscriptions`, body);
|
||||
responseData = await stravaApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/push_subscriptions`,
|
||||
body,
|
||||
);
|
||||
} else {
|
||||
error.message = `A subscription already exists [${webhooks[0].callback_url}]. If you want to delete this subcription and create a new one with the current parameters please go to options and set delete if exist to true`;
|
||||
throw error;
|
||||
@@ -206,7 +215,6 @@ export class StravaTrigger implements INodeType {
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
if (webhookData.webhookId !== undefined) {
|
||||
|
||||
const endpoint = `/push_subscriptions/${webhookData.webhookId}`;
|
||||
|
||||
try {
|
||||
@@ -273,9 +281,7 @@ export class StravaTrigger implements INodeType {
|
||||
}
|
||||
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(body),
|
||||
],
|
||||
workflowData: [this.helpers.returnJsonArray(body)],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user