From 8350305c140f7b43590b4582a981063ed879e1fa Mon Sep 17 00:00:00 2001 From: Anant Anand Gupta Date: Mon, 25 Mar 2024 23:40:32 +0530 Subject: [PATCH] added subscriber's list management feature - with this new node you will be able to add, romove of unsubscribe a user from given list in bulk LucasSovre/listmonk-n8n#4 - fixed a trivial codding issue related to n8n framework (suffix `=`). - updated version to 1.0.6 --- .../businessOperations/subscribers.ts | 16 +++- nodes/Listmonk/options.ts | 78 +++++++++++++++++++ package-lock.json | 4 +- package.json | 2 +- 4 files changed, 96 insertions(+), 4 deletions(-) diff --git a/nodes/Listmonk/businessOperations/subscribers.ts b/nodes/Listmonk/businessOperations/subscribers.ts index 6bd5fce..d166a68 100644 --- a/nodes/Listmonk/businessOperations/subscribers.ts +++ b/nodes/Listmonk/businessOperations/subscribers.ts @@ -19,7 +19,7 @@ export const subscriberOperations: INodeProperties[] = [ routing: { request: { method: 'POST', - url: '=/subscribers', + url: '/subscribers', body: `={{JSON.stringify({"email":$parameter.subscriberEmail, "name":$parameter.name, "status" : $parameter.subscriberStatus, "lists": JSON.parse($parameter.subscriberLists), attribs: JSON.parse($parameter.subscriberAttributes), "preconfirm_subscriptions": Boolean($parameter.preconfirmSubscriptions) })}}`, encoding: 'json', json: true, @@ -87,6 +87,20 @@ export const subscriberOperations: INodeProperties[] = [ }, }, }, + { + name: 'Manage Subscriber List', + value: 'manageSubscribersLists', + action: 'Add or remove multiple subscribers to and from given lists or mark them unsubscribed in list', + routing: { + request: { + method: 'PUT', + url: '/subscribers/lists', + body: '{{JSON.stringify({"ids":JSON.parse($parameter.subscriberIds), "action":$parameter.subscriptionAction, "target_list_ids":JSON.parse($parameter.listIds), "status":$parameter.subscriptionStatus })}}', + encoding: 'json', + json: true, + }, + }, + }, { name: 'Modify a Subscriber', value: 'modifySubscriber', diff --git a/nodes/Listmonk/options.ts b/nodes/Listmonk/options.ts index 3512c4c..e7b6304 100644 --- a/nodes/Listmonk/options.ts +++ b/nodes/Listmonk/options.ts @@ -303,6 +303,84 @@ export const listmonkOptions: INodeProperties[] = [ }, }, }, + { + displayName: 'Subscriber IDs', + name: 'subscriberIDs', + type: 'json', + default: '[]', + displayOptions: { + show: { + operation: ['manageSubscribersLists'], + }, + }, + }, + { + displayName: 'Action', + name: 'subscriptionAction', + type: 'options', + required: true, + options: [ + { + name: 'Add', + value: 'add', + }, + { + name: 'Remove', + value: 'remove', + }, + { + name: 'Unsubscribe', + value: 'unsubscribe', + }, + ], + default: 'add', // The initially selected option + description: 'Subscriber status', + displayOptions: { + // the resources and operations to display this element with + show: { + operation: ['manageSubscribersLists'], + }, + }, + }, + { + displayName: 'List IDs', + description: 'List IDs to add subscribers to', + name: 'listIDs', + type: 'json', + default: '[]', + displayOptions: { + show: { + operation: ['manageSubscribersLists'], + }, + }, + }, + { + displayName: 'Subscription Status', + name: 'subscriptionStatus', + type: 'options', + options: [ + { + name: 'Confirmed', + value: 'confirmed', + }, + { + name: 'Unconfirmed', + value: 'unconfirmed', + }, + { + name: 'Unsubscribed', + value: 'unsubscribed', + }, + ], + default: 'confirmed', // The initially selected option + description: 'Subscriber status', + displayOptions: { + // the resources and operations to display this element with + show: { + operation: ['manageSubscribersLists'], + }, + }, + }, { displayName: 'Lists', description: 'Lists to add the subscriber to', diff --git a/package-lock.json b/package-lock.json index fa26bb5..345f074 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "n8n-nodes-listmonk", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "n8n-nodes-listmonk", - "version": "1.0.5", + "version": "1.0.6", "license": "MIT", "devDependencies": { "@types/express": "^4.17.6", diff --git a/package.json b/package.json index 3eb10bc..3ff6782 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "n8n-nodes-listmonk", - "version": "1.0.5", + "version": "1.0.6", "description": "A n8n node to interact with Listmonk app", "keywords": [ "n8n-community-node-package",