mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
🐛 Fix issue sending tags when creating a conversation (HelpScout) (#1501)
This commit is contained in:
parent
3ff7d3af39
commit
f13a2781a6
|
@ -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<any> { // tslint:disable-line:no-any
|
||||
export async function helpscoutApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
|
|
|
@ -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[]);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 870 B |
6
packages/nodes-base/nodes/HelpScout/helpscout.svg
Normal file
6
packages/nodes-base/nodes/HelpScout/helpscout.svg
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="256px" height="310px" viewBox="0 0 256 310" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||
<g>
|
||||
<path d="M18.432,180.968727 L108.916364,90.4843636 C120.645818,78.9410909 127.906909,62.7432727 127.906909,45.056 C127.906909,27.5549091 120.832,11.5432727 109.474909,0 L18.9905455,90.4843636 C7.26109091,102.027636 0,118.225455 0,135.912727 C0,153.6 7.07490909,169.425455 18.432,180.968727 Z M237.568,128.093091 L147.083636,218.577455 C135.354182,230.120727 128.093091,246.318545 128.093091,264.005818 C128.093091,281.506909 135.168,297.518545 146.525091,309.061818 L237.009455,218.577455 C248.738909,207.034182 256,190.836364 256,173.149091 C256,155.461818 248.925091,139.636364 237.568,128.093091 Z M237.009455,90.6705455 C248.738909,79.1272727 256,62.9294545 256,45.2421818 C256,27.7410909 248.925091,11.7294545 237.568,0.186181818 L18.9905455,218.577455 C7.26109091,230.306909 0,246.318545 0,264.192 C0,281.693091 7.07490909,297.704727 18.432,309.248 L237.009455,90.6705455 Z" fill="#1292EE"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in a new issue