mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
Add scaffolding for post comment
This commit is contained in:
parent
7c1d0ff037
commit
c2f43d8122
|
@ -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',
|
||||
],
|
||||
},
|
||||
},
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue