Skip to content

Commit

Permalink
Merge pull request #5 from anantanandgupta/feature/add-subscribers-to…
Browse files Browse the repository at this point in the history
…-lists

added subscriber's list management feature
  • Loading branch information
LucasSovre authored Mar 25, 2024
2 parents e665957 + 8350305 commit 7abcce6
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 4 deletions.
16 changes: 15 additions & 1 deletion nodes/Listmonk/businessOperations/subscribers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
78 changes: 78 additions & 0 deletions nodes/Listmonk/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 7abcce6

Please sign in to comment.