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,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export const commentOperations = [
|
export const postCommentOperations = [
|
||||||
{
|
{
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
name: 'operation',
|
name: 'operation',
|
||||||
|
@ -11,23 +11,35 @@ export const commentOperations = [
|
||||||
description: 'Operation to perform',
|
description: 'Operation to perform',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'Create',
|
name: 'Add',
|
||||||
value: 'create',
|
value: 'add',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get All',
|
||||||
|
value: 'getAll',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Remove',
|
||||||
|
value: 'remove',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Reply',
|
||||||
|
value: 'reply',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
'comment',
|
'postComment',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
|
||||||
export const commentFields = [
|
export const postCommentFields = [
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// comment: create
|
// postComment: add
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Target ID',
|
displayName: 'Target ID',
|
||||||
|
@ -39,10 +51,10 @@ export const commentFields = [
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
'comment',
|
'postComment',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'create',
|
'add',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -57,10 +69,10 @@ export const commentFields = [
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
'comment',
|
'postComment',
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'create',
|
'add',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
|
@ -15,9 +15,9 @@ import {
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
commentFields,
|
postCommentFields,
|
||||||
commentOperations,
|
postCommentOperations,
|
||||||
} from './CommentDescription';
|
} from './PostCommentDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
postFields,
|
postFields,
|
||||||
|
@ -61,7 +61,7 @@ export class Reddit implements INodeType {
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: [
|
resource: [
|
||||||
'comment',
|
'postComment',
|
||||||
'post',
|
'post',
|
||||||
'profile',
|
'profile',
|
||||||
],
|
],
|
||||||
|
@ -83,6 +83,10 @@ export class Reddit implements INodeType {
|
||||||
name: 'Post',
|
name: 'Post',
|
||||||
value: 'post',
|
value: 'post',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Post Comment',
|
||||||
|
value: 'postComment',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Profile',
|
name: 'Profile',
|
||||||
value: 'profile',
|
value: 'profile',
|
||||||
|
@ -99,8 +103,8 @@ export class Reddit implements INodeType {
|
||||||
default: 'comment',
|
default: 'comment',
|
||||||
description: 'Resource to consume',
|
description: 'Resource to consume',
|
||||||
},
|
},
|
||||||
...commentOperations,
|
...postCommentOperations,
|
||||||
...commentFields,
|
...postCommentFields,
|
||||||
...profileOperations,
|
...profileOperations,
|
||||||
...profileFields,
|
...profileFields,
|
||||||
...subredditOperations,
|
...subredditOperations,
|
||||||
|
@ -124,21 +128,38 @@ export class Reddit implements INodeType {
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
|
||||||
// *********************************************************************
|
// *********************************************************************
|
||||||
// comment
|
// post comment
|
||||||
// *********************************************************************
|
// *********************************************************************
|
||||||
|
|
||||||
if (resource === 'comment') {
|
if (resource === 'postComment') {
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// comment: create
|
// postComment: add
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
const qs: IDataObject = {
|
if (operation === 'add') {
|
||||||
text: this.getNodeParameter('text', i),
|
|
||||||
thing_id: this.getNodeParameter('targetId', i),
|
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
|
// profile
|
||||||
|
|
Loading…
Reference in a new issue