From f13a2781a6133a51d96ff44d659ca1b2967a2b17 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Mon, 1 Mar 2021 17:38:22 -0500 Subject: [PATCH] :bug: Fix issue sending tags when creating a conversation (HelpScout) (#1501) --- .../nodes/HelpScout/GenericFunctions.ts | 12 ++++++---- .../nodes/HelpScout/HelpScout.node.ts | 22 +++++++++--------- .../nodes/HelpScout/HelpScoutTrigger.node.ts | 10 ++++---- .../nodes-base/nodes/HelpScout/helpScout.png | Bin 870 -> 0 bytes .../nodes-base/nodes/HelpScout/helpscout.svg | 6 +++++ 5 files changed, 31 insertions(+), 19 deletions(-) delete mode 100644 packages/nodes-base/nodes/HelpScout/helpScout.png create mode 100644 packages/nodes-base/nodes/HelpScout/helpscout.svg diff --git a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts index 886cfa2b29..ffdde00d10 100644 --- a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts @@ -1,10 +1,14 @@ -import { OptionsWithUri } from 'request'; +import { + OptionsWithUri, +} from 'request'; + import { IExecuteFunctions, IExecuteSingleFunctions, IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; + import { IDataObject, } from 'n8n-workflow'; @@ -35,8 +39,8 @@ export async function helpscoutApiRequest(this: IExecuteFunctions | IExecuteSing return await this.helpers.requestOAuth2.call(this, 'helpScoutOAuth2Api', options); } catch (error) { if (error.response && error.response.body - && error.response.body._embedded - && error.response.body._embedded.errors) { + && error.response.body._embedded + && error.response.body._embedded.errors) { // Try to return the error prettier //@ts-ignore throw new Error(`HelpScout error response [${error.statusCode}]: ${error.response.body.message} - ${error.response.body._embedded.errors.map(error => { @@ -48,7 +52,7 @@ export async function helpscoutApiRequest(this: IExecuteFunctions | IExecuteSing } } -export async function helpscoutApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function helpscoutApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any const returnData: IDataObject[] = []; diff --git a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts index 4b72299179..54f2495682 100644 --- a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts +++ b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts @@ -59,7 +59,7 @@ export class HelpScout implements INodeType { description: INodeTypeDescription = { displayName: 'HelpScout', name: 'helpScout', - icon: 'file:helpScout.png', + icon: 'file:helpScout.svg', group: ['input'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', @@ -139,7 +139,7 @@ export class HelpScout implements INodeType { const tagId = tag.id; returnData.push({ name: tagName, - value: tagId, + value: tagName, }); } return returnData; @@ -391,23 +391,23 @@ export class HelpScout implements INodeType { } if (attachments) { if (attachments.attachmentsValues - && (attachments.attachmentsValues as IDataObject[]).length !== 0) { + && (attachments.attachmentsValues as IDataObject[]).length !== 0) { body.attachments?.push.apply(body.attachments, attachments.attachmentsValues as IAttachment[]); } if (attachments.attachmentsBinary - && (attachments.attachmentsBinary as IDataObject[]).length !== 0 - && items[i].binary) { - const mapFunction = (value: IDataObject): IAttachment => { - const binaryProperty = (items[i].binary as IBinaryKeyData)[value.property as string]; + && (attachments.attachmentsBinary as IDataObject[]).length !== 0 + && items[i].binary) { + const mapFunction = (value: IDataObject): IAttachment => { + const binaryProperty = (items[i].binary as IBinaryKeyData)[value.property as string]; if (binaryProperty) { return { fileName: binaryProperty.fileName || 'unknown', data: binaryProperty.data, mimeType: binaryProperty.mimeType, - }; - } else { - throw new Error(`Binary property ${value.property} does not exist on input`); - } + }; + } else { + throw new Error(`Binary property ${value.property} does not exist on input`); + } }; body.attachments?.push.apply(body.attachments, (attachments.attachmentsBinary as IDataObject[]).map(mapFunction) as IAttachment[]); } diff --git a/packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts b/packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts index 63592aa14e..20a03de3f2 100644 --- a/packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts +++ b/packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts @@ -15,13 +15,15 @@ import { helpscoutApiRequestAllItems, } from './GenericFunctions'; -import { createHmac } from 'crypto'; +import { + createHmac, +} from 'crypto'; export class HelpScoutTrigger implements INodeType { description: INodeTypeDescription = { displayName: 'HelpScout Trigger', name: 'helpScoutTrigger', - icon: 'file:helpScout.png', + icon: 'file:helpScout.svg', group: ['trigger'], version: 1, description: 'Starts the workflow when HelpScout events occure.', @@ -125,7 +127,7 @@ export class HelpScoutTrigger implements INodeType { if (webhook.url === webhookUrl) { for (const event of events) { if (!webhook.events.includes(event) - && webhook.state === 'enabled') { + && webhook.state === 'enabled') { return false; } } @@ -186,7 +188,7 @@ export class HelpScoutTrigger implements INodeType { const bodyData = this.getBodyData(); const headerData = this.getHeaderData() as IDataObject; const webhookData = this.getWorkflowStaticData('node'); - if (headerData['x-helpscout-signature'] === undefined) { + if (headerData['x-helpscout-signature'] === undefined) { return {}; } //@ts-ignore diff --git a/packages/nodes-base/nodes/HelpScout/helpScout.png b/packages/nodes-base/nodes/HelpScout/helpScout.png deleted file mode 100644 index 1ebdaa8e5e17325e79cec03c48aa5321c6e5e2a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 870 zcmV-s1DX7ZP)@ch{2 z`Z<{IHJ9%klkV~M{YsthKAP|2?EA>u_(h!WT%+*y`TlUL@zLS>-|G8OpYOBH_I*oB#jceO@hvM9nLXkUCmgpvqQc@4TUvUL=YNXIIXHXJ%Qo_pp+AB@YqbRmVIlV!}I|}V^ z#-b_SjPv4^-x1TtG8j;{a$#{_`U)t;LKKyXy4Q0RP!7GU1n96Co;SUonn7X4lq?M| z$$Tb>r&JRZj+9Vkof-VtWK$F!PAw(uj=GRyWg(9viUku+KP}HV>qIFgD1|&+g6YS! z`FQrM53-=M_mmQJom_%(qoGANj&elGq8?M!L%Ey4{Hc_EXVq?R3V_v^!d&`Y@{k=j zHb{9hCBSw}Nv~b{h35t-ttlob;u@EJG{s0MrzorF^kWK&?Kv+dDP8*Ag6YSUkYN9z zSlVwNt3gi1C%pJmqmv5%|4(@F3ZCPq;o zDl<5IF1beZaGn+IThqW wQx9>NA$M~)YU0_aB4r+F;@Rv~ulnir7wLQ}BpcsNu>b%707*qoM6N<$g5(>qegFUf diff --git a/packages/nodes-base/nodes/HelpScout/helpscout.svg b/packages/nodes-base/nodes/HelpScout/helpscout.svg new file mode 100644 index 0000000000..2645eaa983 --- /dev/null +++ b/packages/nodes-base/nodes/HelpScout/helpscout.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file