From 3271c8d78b4f05b2741d81a2518a43de358abacd Mon Sep 17 00:00:00 2001 From: Florian Gareis Date: Mon, 27 Jan 2025 15:44:03 +0000 Subject: [PATCH] Add option to send message directly to phone number AWS SNS --- packages/nodes-base/nodes/Aws/AwsSns.node.ts | 53 +++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Aws/AwsSns.node.ts b/packages/nodes-base/nodes/Aws/AwsSns.node.ts index 858f93774a..43ab0c9aa8 100644 --- a/packages/nodes-base/nodes/Aws/AwsSns.node.ts +++ b/packages/nodes-base/nodes/Aws/AwsSns.node.ts @@ -101,6 +101,32 @@ export class AwsSns implements INodeType { }, }, }, + { + displayName: 'Target', + name: 'target', + type: 'options', + noDataExpression: true, + options: [ + { + name: 'Topic', + value: 'topic', + description: 'Publish to a topic', + action: 'Publish to a topic', + }, + { + name: 'Phone', + value: 'phone', + description: 'Publish to a phone number', + action: 'Publish to a phone number', + }, + ], + default: 'topic', + displayOptions: { + show: { + operation: ['publish'], + }, + }, + }, { displayName: 'Topic', name: 'topic', @@ -159,9 +185,24 @@ export class AwsSns implements INodeType { displayOptions: { show: { operation: ['publish', 'delete'], + target: ['topic'], }, }, }, + { + displayName: 'Number', + name: 'number', + type: 'string', + displayOptions: { + show: { + target: ['phone'], + }, + }, + default: '', + placeholder: '+123456789', + required: true, + description: 'The number where the message is published to', + }, { displayName: 'Subject', name: 'subject', @@ -300,13 +341,23 @@ export class AwsSns implements INodeType { const topic = this.getNodeParameter('topic', i, undefined, { extractValue: true, }) as string; + const number = this.getNodeParameter('number', i, undefined, { + extractValue: true, + }) as string; + const target = this.getNodeParameter('mode', 0); const params = [ - 'TopicArn=' + topic, 'Subject=' + encodeURIComponent(this.getNodeParameter('subject', i) as string), 'Message=' + encodeURIComponent(this.getNodeParameter('message', i) as string), ]; + if (target === 'topic') { + params.push('TopicArn=' + topic) + } + if (target === 'phone') { + params.push('PhoneNumber=' + number) + } + const responseData = await awsApiRequestSOAP.call( this, 'sns',