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,17 +1,20 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import _ from 'lodash';
|
||||
import { NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
||||
import { NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
export async function mandrillApiRequest(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, resource: string, method: string, action: string, body: any = {}, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function mandrillApiRequest(
|
||||
this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
resource: string,
|
||||
method: string,
|
||||
action: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
headers?: object,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('mandrillApi');
|
||||
|
||||
const data = Object.assign({}, body, { key: credentials.apiKey });
|
||||
@@ -26,7 +29,6 @@ export async function mandrillApiRequest(this: IExecuteFunctions | IHookFunction
|
||||
json: true,
|
||||
};
|
||||
|
||||
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
@@ -34,7 +36,8 @@ export async function mandrillApiRequest(this: IExecuteFunctions | IHookFunction
|
||||
}
|
||||
}
|
||||
|
||||
export function getToEmailArray(toEmail: string): any { // tslint:disable-line:no-any
|
||||
// tslint:disable-next-line:no-any
|
||||
export function getToEmailArray(toEmail: string): any {
|
||||
let toEmailArray;
|
||||
if (toEmail.split(',').length > 0) {
|
||||
const array = toEmail.split(',');
|
||||
@@ -45,10 +48,12 @@ export function getToEmailArray(toEmail: string): any { // tslint:disable-line:n
|
||||
};
|
||||
});
|
||||
} else {
|
||||
toEmailArray = [{
|
||||
email: toEmail,
|
||||
type: 'to',
|
||||
}];
|
||||
toEmailArray = [
|
||||
{
|
||||
email: toEmail,
|
||||
type: 'to',
|
||||
},
|
||||
];
|
||||
}
|
||||
return toEmailArray;
|
||||
}
|
||||
@@ -63,7 +68,8 @@ export function getGoogleAnalyticsDomainsArray(s: string): string[] {
|
||||
return array;
|
||||
}
|
||||
|
||||
export function getTags(s: string): any[] { // tslint:disable-line:no-any
|
||||
// tslint:disable-next-line:no-any
|
||||
export function getTags(s: string): any[] {
|
||||
let array = [];
|
||||
if (s.split(',').length > 0) {
|
||||
array = s.split(',');
|
||||
@@ -73,7 +79,8 @@ export function getTags(s: string): any[] { // tslint:disable-line:no-any
|
||||
return array;
|
||||
}
|
||||
|
||||
export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any
|
||||
// tslint:disable-next-line:no-any
|
||||
export function validateJSON(json: string | undefined): any {
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(json!);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -18,7 +16,7 @@ import {
|
||||
getTags,
|
||||
getToEmailArray,
|
||||
mandrillApiRequest,
|
||||
validateJSON
|
||||
validateJSON,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import moment from 'moment';
|
||||
@@ -139,9 +137,7 @@ export class Mandrill implements INodeType {
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
resource: ['message'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -169,15 +165,14 @@ export class Mandrill implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'sendTemplate',
|
||||
],
|
||||
operation: ['sendTemplate'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
options: [],
|
||||
required: true,
|
||||
description: 'The template you want to send. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The template you want to send. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'From Email',
|
||||
@@ -189,10 +184,7 @@ export class Mandrill implements INodeType {
|
||||
description: 'Email address of the sender optional with name',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'sendHtml',
|
||||
'sendTemplate',
|
||||
],
|
||||
operation: ['sendHtml', 'sendTemplate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -206,10 +198,7 @@ export class Mandrill implements INodeType {
|
||||
description: 'Email address of the recipient. Multiple ones can be separated by comma.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'sendHtml',
|
||||
'sendTemplate',
|
||||
],
|
||||
operation: ['sendHtml', 'sendTemplate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -220,10 +209,7 @@ export class Mandrill implements INodeType {
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'sendHtml',
|
||||
'sendTemplate',
|
||||
],
|
||||
operation: ['sendHtml', 'sendTemplate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -235,10 +221,7 @@ export class Mandrill implements INodeType {
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'sendHtml',
|
||||
'sendTemplate',
|
||||
],
|
||||
operation: ['sendHtml', 'sendTemplate'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -247,21 +230,24 @@ export class Mandrill implements INodeType {
|
||||
name: 'async',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the \'reject\' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.',
|
||||
description:
|
||||
'Whether to enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the \'reject\' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.',
|
||||
},
|
||||
{
|
||||
displayName: 'Auto Text',
|
||||
name: 'autoText',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether or not to automatically generate a text part for messages that are not given text',
|
||||
description:
|
||||
'Whether or not to automatically generate a text part for messages that are not given text',
|
||||
},
|
||||
{
|
||||
displayName: 'Auto HTML',
|
||||
name: 'autoHtml',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether or not to automatically generate an HTML part for messages that are not given HTML',
|
||||
description:
|
||||
'Whether or not to automatically generate an HTML part for messages that are not given HTML',
|
||||
},
|
||||
{
|
||||
displayName: 'BCC Address',
|
||||
@@ -269,7 +255,7 @@ export class Mandrill implements INodeType {
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'message.bcc_address@example.com',
|
||||
description: 'An optional address to receive an exact copy of each recipient\'s email',
|
||||
description: "An optional address to receive an exact copy of each recipient's email",
|
||||
},
|
||||
{
|
||||
displayName: 'From Name',
|
||||
@@ -285,7 +271,8 @@ export class Mandrill implements INodeType {
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'Optional string indicating the value to set for the utm_campaign tracking parameter. If this isn\'t provided the email\'s from address will be used instead.',
|
||||
description:
|
||||
"Optional string indicating the value to set for the utm_campaign tracking parameter. If this isn't provided the email's from address will be used instead.",
|
||||
},
|
||||
{
|
||||
displayName: 'Google Analytics Domains',
|
||||
@@ -293,7 +280,8 @@ export class Mandrill implements INodeType {
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'An array of strings separated by a comma (,) indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically',
|
||||
description:
|
||||
'An array of strings separated by a comma (,) indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically',
|
||||
},
|
||||
{
|
||||
displayName: 'HTML',
|
||||
@@ -311,14 +299,16 @@ export class Mandrill implements INodeType {
|
||||
name: 'important',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether or not this message is important, and should be delivered ahead of non-important messages',
|
||||
description:
|
||||
'Whether or not this message is important, and should be delivered ahead of non-important messages',
|
||||
},
|
||||
{
|
||||
displayName: 'Inline CSS',
|
||||
name: 'inlineCss',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size',
|
||||
description:
|
||||
'Whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size',
|
||||
},
|
||||
{
|
||||
displayName: 'Ip Pool',
|
||||
@@ -326,7 +316,8 @@ export class Mandrill implements INodeType {
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'The name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.',
|
||||
description:
|
||||
'The name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.',
|
||||
},
|
||||
{
|
||||
displayName: 'Preserve Recipients',
|
||||
@@ -341,7 +332,7 @@ export class Mandrill implements INodeType {
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'A custom domain to use for the messages\'s return-path',
|
||||
description: "A custom domain to use for the messages's return-path",
|
||||
},
|
||||
{
|
||||
displayName: 'Sent At',
|
||||
@@ -349,7 +340,8 @@ export class Mandrill implements INodeType {
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'When this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately. An additional fee applies for scheduled email, and this feature is only available to accounts with a positive balance.',
|
||||
description:
|
||||
'When this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately. An additional fee applies for scheduled email, and this feature is only available to accounts with a positive balance.',
|
||||
},
|
||||
{
|
||||
displayName: 'Signing Domain',
|
||||
@@ -357,7 +349,8 @@ export class Mandrill implements INodeType {
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'A custom domain to use for SPF/DKIM signing instead of mandrill(for "via" or "on behalf of" in email clients)',
|
||||
description:
|
||||
'A custom domain to use for SPF/DKIM signing instead of mandrill(for "via" or "on behalf of" in email clients)',
|
||||
},
|
||||
{
|
||||
displayName: 'Subaccount',
|
||||
@@ -365,7 +358,8 @@ export class Mandrill implements INodeType {
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'The unique ID of a subaccount for this message - must already exist or will fail with an error',
|
||||
description:
|
||||
'The unique ID of a subaccount for this message - must already exist or will fail with an error',
|
||||
},
|
||||
{
|
||||
displayName: 'Subject',
|
||||
@@ -381,7 +375,8 @@ export class Mandrill implements INodeType {
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'An array of string separated by a comma (,) to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors.',
|
||||
description:
|
||||
'An array of string separated by a comma (,) to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors.',
|
||||
},
|
||||
{
|
||||
displayName: 'Text',
|
||||
@@ -414,14 +409,16 @@ export class Mandrill implements INodeType {
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: '',
|
||||
description: 'A custom domain to use for tracking opens and clicks instead of mandrillapp.com',
|
||||
description:
|
||||
'A custom domain to use for tracking opens and clicks instead of mandrillapp.com',
|
||||
},
|
||||
{
|
||||
displayName: 'Url Strip Qs',
|
||||
name: 'urlStripQs',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether or not to strip the query string from URLs when aggregating tracked URL data',
|
||||
description:
|
||||
'Whether or not to strip the query string from URLs when aggregating tracked URL data',
|
||||
},
|
||||
{
|
||||
displayName: 'View Content Link',
|
||||
@@ -447,9 +444,7 @@ export class Mandrill implements INodeType {
|
||||
]`,
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
description: 'Global merge variables',
|
||||
@@ -465,9 +460,7 @@ export class Mandrill implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
description: 'Per-recipient merge variables',
|
||||
@@ -503,12 +496,11 @@ export class Mandrill implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
description: 'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.',
|
||||
description:
|
||||
'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.',
|
||||
options: [
|
||||
{
|
||||
name: 'metadataValues',
|
||||
@@ -540,16 +532,15 @@ export class Mandrill implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
placeholder: `{
|
||||
"website": "www.example.com"
|
||||
}`,
|
||||
description: 'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.',
|
||||
description:
|
||||
'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.',
|
||||
},
|
||||
{
|
||||
displayName: 'Attachments',
|
||||
@@ -560,9 +551,7 @@ export class Mandrill implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -585,9 +574,7 @@ export class Mandrill implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -630,7 +617,8 @@ export class Mandrill implements INodeType {
|
||||
name: 'property',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the binary properties which contain data which should be added to email as attachment',
|
||||
description:
|
||||
'Name of the binary properties which contain data which should be added to email as attachment',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -648,9 +636,7 @@ export class Mandrill implements INodeType {
|
||||
}`,
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -669,9 +655,7 @@ export class Mandrill implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -726,7 +710,6 @@ export class Mandrill implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const returnData: IDataObject[] = [];
|
||||
const items = this.getInputData();
|
||||
@@ -738,7 +721,6 @@ export class Mandrill implements INodeType {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
if (resource === 'message') {
|
||||
|
||||
const options = this.getNodeParameter('options', i) as Options;
|
||||
const fromEmail = this.getNodeParameter('fromEmail', i) as string;
|
||||
const toEmail = this.getNodeParameter('toEmail', i) as string;
|
||||
@@ -746,31 +728,35 @@ export class Mandrill implements INodeType {
|
||||
const toEmailArray = getToEmailArray(toEmail);
|
||||
|
||||
const message: Message = {
|
||||
html: (options.html) ? options.html : '',
|
||||
text: (options.text) ? options.text : '',
|
||||
subject: (options.subject) ? options.subject : '',
|
||||
html: options.html ? options.html : '',
|
||||
text: options.text ? options.text : '',
|
||||
subject: options.subject ? options.subject : '',
|
||||
from_email: fromEmail,
|
||||
to: toEmailArray,
|
||||
important: (options.important) ? options.important : false,
|
||||
track_opens: (options.trackOpens) ? options.trackOpens : false,
|
||||
track_clicks: (options.trackClicks) ? options.trackClicks : false,
|
||||
auto_text: (options.autoText) ? options.autoText : false,
|
||||
auto_html: (options.autoHtml) ? options.autoHtml : false,
|
||||
inline_css: (options.inlineCss) ? options.inlineCss : false,
|
||||
url_strip_qs: (options.urlStripQs) ? options.urlStripQs : false,
|
||||
preserve_recipients: (options.preserveRecipients) ? options.preserveRecipients : false,
|
||||
view_content_link: (options.viewContentLink) ? options.viewContentLink : false,
|
||||
async: (options.async) ? options.async : false,
|
||||
google_analytics_campaign: (options.googleAnalyticsCampaign) ? options.googleAnalyticsCampaign : '',
|
||||
ip_pool: (options.ipPool) ? options.ipPool : '',
|
||||
bcc_address: (options.bccAddress) ? options.bccAddress : '',
|
||||
tracking_domain: (options.trackingDomain) ? options.trackingDomain : '',
|
||||
signing_domain: (options.signingDomain) ? options.signingDomain : '',
|
||||
return_path_domain: (options.returnPathDomain) ? options.returnPathDomain : '',
|
||||
important: options.important ? options.important : false,
|
||||
track_opens: options.trackOpens ? options.trackOpens : false,
|
||||
track_clicks: options.trackClicks ? options.trackClicks : false,
|
||||
auto_text: options.autoText ? options.autoText : false,
|
||||
auto_html: options.autoHtml ? options.autoHtml : false,
|
||||
inline_css: options.inlineCss ? options.inlineCss : false,
|
||||
url_strip_qs: options.urlStripQs ? options.urlStripQs : false,
|
||||
preserve_recipients: options.preserveRecipients ? options.preserveRecipients : false,
|
||||
view_content_link: options.viewContentLink ? options.viewContentLink : false,
|
||||
async: options.async ? options.async : false,
|
||||
google_analytics_campaign: options.googleAnalyticsCampaign
|
||||
? options.googleAnalyticsCampaign
|
||||
: '',
|
||||
ip_pool: options.ipPool ? options.ipPool : '',
|
||||
bcc_address: options.bccAddress ? options.bccAddress : '',
|
||||
tracking_domain: options.trackingDomain ? options.trackingDomain : '',
|
||||
signing_domain: options.signingDomain ? options.signingDomain : '',
|
||||
return_path_domain: options.returnPathDomain ? options.returnPathDomain : '',
|
||||
};
|
||||
|
||||
if (options.googleAnalyticsDomains) {
|
||||
message.google_analytics_domains = getGoogleAnalyticsDomainsArray(options.googleAnalyticsDomains);
|
||||
message.google_analytics_domains = getGoogleAnalyticsDomainsArray(
|
||||
options.googleAnalyticsDomains,
|
||||
);
|
||||
}
|
||||
|
||||
if (options.tags) {
|
||||
@@ -795,14 +781,17 @@ export class Mandrill implements INodeType {
|
||||
}
|
||||
|
||||
if (jsonActive) {
|
||||
|
||||
body.message.headers = validateJSON(this.getNodeParameter('headersJson', i) as string);
|
||||
body.message.metadata = validateJSON(this.getNodeParameter('metadataJson', i) as string);
|
||||
body.message.global_merge_vars = validateJSON(this.getNodeParameter('mergeVarsJson', i) as string);
|
||||
body.message.attachments = validateJSON(this.getNodeParameter('attachmentsJson', i) as string);
|
||||
|
||||
body.message.metadata = validateJSON(
|
||||
this.getNodeParameter('metadataJson', i) as string,
|
||||
);
|
||||
body.message.global_merge_vars = validateJSON(
|
||||
this.getNodeParameter('mergeVarsJson', i) as string,
|
||||
);
|
||||
body.message.attachments = validateJSON(
|
||||
this.getNodeParameter('attachmentsJson', i) as string,
|
||||
);
|
||||
} else {
|
||||
|
||||
const headersUi = this.getNodeParameter('headersUi', i) as IDataObject;
|
||||
if (!_.isEmpty(headersUi)) {
|
||||
// @ts-ignore
|
||||
@@ -827,20 +816,26 @@ export class Mandrill implements INodeType {
|
||||
const mergeVarsUi = this.getNodeParameter('mergeVarsUi', i) as IDataObject;
|
||||
if (!_.isEmpty(mergeVarsUi)) {
|
||||
// @ts-ignore
|
||||
body.message.global_merge_vars = _.map(mergeVarsUi.mergeVarsValues, (o: IDataObject) => {
|
||||
const aux: IDataObject = {};
|
||||
aux.name = o.name;
|
||||
aux.content = o.content;
|
||||
return aux;
|
||||
});
|
||||
body.message.global_merge_vars = _.map(
|
||||
// @ts-ignore
|
||||
mergeVarsUi.mergeVarsValues,
|
||||
(o: IDataObject) => {
|
||||
const aux: IDataObject = {};
|
||||
aux.name = o.name;
|
||||
aux.content = o.content;
|
||||
return aux;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
const attachmentsUi = this.getNodeParameter('attachmentsUi', i) as IDataObject;
|
||||
let attachmentsBinary: Attachments[] = [], attachmentsValues: Attachments[] = [];
|
||||
let attachmentsBinary: Attachments[] = [],
|
||||
attachmentsValues: Attachments[] = [];
|
||||
if (!_.isEmpty(attachmentsUi)) {
|
||||
|
||||
if (attachmentsUi.hasOwnProperty('attachmentsValues')
|
||||
&& !_.isEmpty(attachmentsUi.attachmentsValues)) {
|
||||
if (
|
||||
attachmentsUi.hasOwnProperty('attachmentsValues') &&
|
||||
!_.isEmpty(attachmentsUi.attachmentsValues)
|
||||
) {
|
||||
// @ts-ignore
|
||||
attachmentsValues = _.map(attachmentsUi.attachmentsValues, (o: IDataObject) => {
|
||||
const aux: IDataObject = {};
|
||||
@@ -852,9 +847,11 @@ export class Mandrill implements INodeType {
|
||||
});
|
||||
}
|
||||
|
||||
if (attachmentsUi.hasOwnProperty('attachmentsBinary')
|
||||
&& !_.isEmpty(attachmentsUi.attachmentsBinary)
|
||||
&& items[i].binary) {
|
||||
if (
|
||||
attachmentsUi.hasOwnProperty('attachmentsBinary') &&
|
||||
!_.isEmpty(attachmentsUi.attachmentsBinary) &&
|
||||
items[i].binary
|
||||
) {
|
||||
// @ts-ignore
|
||||
attachmentsBinary = _.map(attachmentsUi.attachmentsBinary, (o: IDataObject) => {
|
||||
if (items[i].binary!.hasOwnProperty(o.property as string)) {
|
||||
@@ -874,7 +871,13 @@ export class Mandrill implements INodeType {
|
||||
if (operation === 'sendTemplate') {
|
||||
const template = this.getNodeParameter('template', i) as string;
|
||||
body.template_name = template;
|
||||
emailSentResponse = mandrillApiRequest.call(this, '/messages', 'POST', '/send-template', body);
|
||||
emailSentResponse = mandrillApiRequest.call(
|
||||
this,
|
||||
'/messages',
|
||||
'POST',
|
||||
'/send-template',
|
||||
body,
|
||||
);
|
||||
} else if (operation === 'sendHtml') {
|
||||
emailSentResponse = mandrillApiRequest.call(this, '/messages', 'POST', '/send', body);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user