diff --git a/packages/nodes-base/nodes/Reddit/CommentDescription.ts b/packages/nodes-base/nodes/Reddit/PostCommentDescription.ts similarity index 70% rename from packages/nodes-base/nodes/Reddit/CommentDescription.ts rename to packages/nodes-base/nodes/Reddit/PostCommentDescription.ts index eefbf406ef..ad9a3d0230 100644 --- a/packages/nodes-base/nodes/Reddit/CommentDescription.ts +++ b/packages/nodes-base/nodes/Reddit/PostCommentDescription.ts @@ -2,7 +2,7 @@ import { INodeProperties, } from 'n8n-workflow'; -export const commentOperations = [ +export const postCommentOperations = [ { displayName: 'Operation', name: 'operation', @@ -11,23 +11,35 @@ export const commentOperations = [ description: 'Operation to perform', options: [ { - name: 'Create', - value: 'create', + name: 'Add', + value: 'add', + }, + { + name: 'Get All', + value: 'getAll', + }, + { + name: 'Remove', + value: 'remove', + }, + { + name: 'Reply', + value: 'reply', }, ], displayOptions: { show: { resource: [ - 'comment', + 'postComment', ], }, }, }, ] as INodeProperties[]; -export const commentFields = [ +export const postCommentFields = [ // ---------------------------------- - // comment: create + // postComment: add // ---------------------------------- { displayName: 'Target ID', @@ -39,10 +51,10 @@ export const commentFields = [ displayOptions: { show: { resource: [ - 'comment', + 'postComment', ], operation: [ - 'create', + 'add', ], }, }, @@ -57,10 +69,10 @@ export const commentFields = [ displayOptions: { show: { resource: [ - 'comment', + 'postComment', ], operation: [ - 'create', + 'add', ], }, }, diff --git a/packages/nodes-base/nodes/Reddit/Reddit.node.ts b/packages/nodes-base/nodes/Reddit/Reddit.node.ts index 19b2dd8284..f088bff595 100644 --- a/packages/nodes-base/nodes/Reddit/Reddit.node.ts +++ b/packages/nodes-base/nodes/Reddit/Reddit.node.ts @@ -15,9 +15,9 @@ import { } from './GenericFunctions'; import { - commentFields, - commentOperations, -} from './CommentDescription'; + postCommentFields, + postCommentOperations, +} from './PostCommentDescription'; import { postFields, @@ -61,7 +61,7 @@ export class Reddit implements INodeType { displayOptions: { show: { resource: [ - 'comment', + 'postComment', 'post', 'profile', ], @@ -83,6 +83,10 @@ export class Reddit implements INodeType { name: 'Post', value: 'post', }, + { + name: 'Post Comment', + value: 'postComment', + }, { name: 'Profile', value: 'profile', @@ -99,8 +103,8 @@ export class Reddit implements INodeType { default: 'comment', description: 'Resource to consume', }, - ...commentOperations, - ...commentFields, + ...postCommentOperations, + ...postCommentFields, ...profileOperations, ...profileFields, ...subredditOperations, @@ -124,21 +128,38 @@ export class Reddit implements INodeType { for (let i = 0; i < items.length; i++) { // ********************************************************************* - // comment + // post comment // ********************************************************************* - if (resource === 'comment') { + if (resource === 'postComment') { // ---------------------------------- - // comment: create + // postComment: add // ---------------------------------- - const qs: IDataObject = { - text: this.getNodeParameter('text', i), - thing_id: this.getNodeParameter('targetId', i), - }; + if (operation === 'add') { + + const qs: IDataObject = { + text: this.getNodeParameter('text', i), + thing_id: this.getNodeParameter('targetId', i), + }; + + responseData = await redditApiRequest.call(this, 'POST', 'api/comment', qs); + + } else if (operation === 'getAll') { + + // ... + + } else if (operation === 'remove') { + + // ... + + } else if (operation === 'reply') { + + // ... + + } - responseData = await redditApiRequest.call(this, 'POST', 'api/comment', qs); // ********************************************************************* // profile