mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Merge 477170174b
into 9e83ff51da
This commit is contained in:
commit
a54380f3e3
|
@ -1081,16 +1081,11 @@ export class AwsSes implements INodeType {
|
||||||
|
|
||||||
if (operation === 'sendTemplate') {
|
if (operation === 'sendTemplate') {
|
||||||
const toAddresses = this.getNodeParameter('toAddresses', i) as string[];
|
const toAddresses = this.getNodeParameter('toAddresses', i) as string[];
|
||||||
|
|
||||||
const template = this.getNodeParameter('templateName', i) as string;
|
const template = this.getNodeParameter('templateName', i) as string;
|
||||||
|
|
||||||
const fromEmail = this.getNodeParameter('fromEmail', i) as string;
|
const fromEmail = this.getNodeParameter('fromEmail', i) as string;
|
||||||
|
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||||
|
|
||||||
const templateDataUi = this.getNodeParameter('templateDataUi', i) as IDataObject;
|
const templateDataUi = this.getNodeParameter('templateDataUi', i) as IDataObject;
|
||||||
|
const params = [`Template=${template}`, `Source=${encodeURIComponent(fromEmail)}`];
|
||||||
const params = [`Template=${template}`, `Source=${fromEmail}`];
|
|
||||||
|
|
||||||
if (toAddresses.length) {
|
if (toAddresses.length) {
|
||||||
setParameter(params, 'Destination.ToAddresses.member', toAddresses);
|
setParameter(params, 'Destination.ToAddresses.member', toAddresses);
|
||||||
|
@ -1150,7 +1145,7 @@ export class AwsSes implements INodeType {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
templateData[templateDataValue.key] = templateDataValue.value;
|
templateData[templateDataValue.key] = templateDataValue.value;
|
||||||
}
|
}
|
||||||
params.push(`TemplateData=${JSON.stringify(templateData)}`);
|
params.push(`TemplateData=${encodeURIComponent(JSON.stringify(templateData))}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1176,13 +1171,15 @@ export class AwsSes implements INodeType {
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||||
|
|
||||||
const params = [
|
const params = [
|
||||||
`Template.TemplateName=${templateName}`,
|
`Template.TemplateName=${encodeURIComponent(templateName)}`,
|
||||||
`Template.SubjectPart=${subjectPart}`,
|
`Template.SubjectPart=${encodeURIComponent(subjectPart)}`,
|
||||||
`Template.HtmlPart=<h1>${htmlPart}</h1>`,
|
`Template.HtmlPart=${encodeURIComponent(htmlPart)}`,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (additionalFields.textPart) {
|
if (additionalFields.textPart) {
|
||||||
params.push(`Template.TextPart=${additionalFields.textPart}`);
|
params.push(
|
||||||
|
`Template.TextPart=${encodeURIComponent(additionalFields.textPart as string)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await awsApiRequestSOAP.call(
|
responseData = await awsApiRequestSOAP.call(
|
||||||
|
@ -1256,18 +1253,24 @@ export class AwsSes implements INodeType {
|
||||||
|
|
||||||
const updateFields = this.getNodeParameter('updateFields', i);
|
const updateFields = this.getNodeParameter('updateFields', i);
|
||||||
|
|
||||||
const params = [`Template.TemplateName=${templateName}`];
|
const params = [`Template.TemplateName=${encodeURIComponent(templateName)}`];
|
||||||
|
|
||||||
if (updateFields.textPart) {
|
if (updateFields.textPart) {
|
||||||
params.push(`Template.TextPart=${updateFields.textPart}`);
|
params.push(
|
||||||
|
`Template.TextPart=${encodeURIComponent(updateFields.textPart as string)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateFields.subjectPart) {
|
if (updateFields.subjectPart) {
|
||||||
params.push(`Template.SubjectPart=${updateFields.subjectPart}`);
|
params.push(
|
||||||
|
`Template.SubjectPart=${encodeURIComponent(updateFields.subjectPart as string)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateFields.subjectPart) {
|
if (updateFields.subjectPart) {
|
||||||
params.push(`Template.HtmlPart=${updateFields.htmlPart}`);
|
params.push(
|
||||||
|
`Template.HtmlPart=${encodeURIComponent(updateFields.htmlPart as string)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await awsApiRequestSOAP.call(
|
responseData = await awsApiRequestSOAP.call(
|
||||||
|
|
|
@ -90,6 +90,96 @@ describe('AwsSes Node', () => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: 'should URIencode params for sending email with template',
|
||||||
|
input: {
|
||||||
|
workflowData: {
|
||||||
|
nodes: [
|
||||||
|
{
|
||||||
|
parameters: {},
|
||||||
|
type: 'n8n-nodes-base.manualTrigger',
|
||||||
|
typeVersion: 1,
|
||||||
|
position: [-180, 520],
|
||||||
|
id: '363e874a-9054-4a64-bc3f-786719dde626',
|
||||||
|
name: "When clicking 'Test workflow'",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
parameters: {
|
||||||
|
operation: 'sendTemplate',
|
||||||
|
templateName: '=Template11',
|
||||||
|
fromEmail: 'test+user@example.com',
|
||||||
|
toAddresses: ['test+user@example.com'],
|
||||||
|
templateDataUi: {
|
||||||
|
templateDataValues: [
|
||||||
|
{
|
||||||
|
key: 'Name',
|
||||||
|
value: '=Special. Characters @#$%^&*()_-',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
additionalFields: {},
|
||||||
|
},
|
||||||
|
type: 'n8n-nodes-base.awsSes',
|
||||||
|
typeVersion: 1,
|
||||||
|
position: [60, 520],
|
||||||
|
id: '13bbf4ef-8320-45d1-9210-61b62794a108',
|
||||||
|
name: 'AWS SES4',
|
||||||
|
credentials: {
|
||||||
|
aws: {
|
||||||
|
id: 'Nz0QZhzu3MvfK4TQ',
|
||||||
|
name: 'AWS account',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
connections: {
|
||||||
|
"When clicking 'Test workflow'": {
|
||||||
|
main: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
node: 'AWS SES4',
|
||||||
|
type: NodeConnectionType.Main,
|
||||||
|
index: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
nodeExecutionOrder: ['Start'],
|
||||||
|
nodeData: { 'AWS SES': [[{ json: { success: 'true' } }]] },
|
||||||
|
},
|
||||||
|
nock: {
|
||||||
|
baseUrl: 'https://email.eu-central-1.amazonaws.com',
|
||||||
|
mocks: [
|
||||||
|
{
|
||||||
|
method: 'post',
|
||||||
|
path: '/',
|
||||||
|
requestBody: (body: any) => {
|
||||||
|
assert.deepEqual(qs.parse(body), {
|
||||||
|
Action: 'SendTemplatedEmail',
|
||||||
|
TemplateName: '=Template11',
|
||||||
|
Source: encodeURIComponent('test+user@example.com'),
|
||||||
|
Destination: {
|
||||||
|
ToAddresses: [encodeURIComponent('test+user@example.com')],
|
||||||
|
},
|
||||||
|
TemplateData: encodeURIComponent(
|
||||||
|
JSON.stringify({
|
||||||
|
Name: '=Special. Characters @#$%^&*()_-',
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
statusCode: 200,
|
||||||
|
responseBody:
|
||||||
|
'<SendTemplatedEmailResponse><success>true</success></SendTemplatedEmailResponse>',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const nodeTypes = Helpers.setup(tests);
|
const nodeTypes = Helpers.setup(tests);
|
||||||
|
|
Loading…
Reference in a new issue