@rjsebening/n8n-nodes-learningsuite 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,6 +16,12 @@ exports.communityProperties = [
|
|
|
16
16
|
description: 'Assign one or more badges to a member',
|
|
17
17
|
action: 'Assign badges to member',
|
|
18
18
|
},
|
|
19
|
+
{
|
|
20
|
+
name: 'Create Community Post',
|
|
21
|
+
value: 'createCommunityPost',
|
|
22
|
+
description: 'Create a community post or answer in a discussion',
|
|
23
|
+
action: 'Create community post',
|
|
24
|
+
},
|
|
19
25
|
{
|
|
20
26
|
name: 'Create Community Post Comment',
|
|
21
27
|
value: 'commentOnPost',
|
|
@@ -132,9 +138,10 @@ exports.communityProperties = [
|
|
|
132
138
|
name: 'authorUserId',
|
|
133
139
|
type: 'options',
|
|
134
140
|
typeOptions: { loadOptionsMethod: 'teamMember_getTeamMembersById' },
|
|
135
|
-
displayOptions: { show: { resource: ['community'], operation: ['commentOnPost'] } },
|
|
141
|
+
displayOptions: { show: { resource: ['community'], operation: ['commentOnPost', 'createCommunityPost'] } },
|
|
136
142
|
default: '',
|
|
137
|
-
|
|
143
|
+
required: true,
|
|
144
|
+
description: 'Select a team member as author. The author must have access to the target forum. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
138
145
|
},
|
|
139
146
|
{
|
|
140
147
|
displayName: 'Comment Text',
|
|
@@ -191,23 +198,78 @@ exports.communityProperties = [
|
|
|
191
198
|
type: 'options',
|
|
192
199
|
typeOptions: { loadOptionsMethod: 'community_getAreas' },
|
|
193
200
|
displayOptions: {
|
|
194
|
-
show: { resource: ['community'], operation: ['getCommunityPosts'] },
|
|
201
|
+
show: { resource: ['community'], operation: ['getCommunityPosts', 'createCommunityPost'] },
|
|
195
202
|
},
|
|
196
203
|
default: '',
|
|
197
204
|
placeholder: 'Select Area (optional)',
|
|
198
|
-
description: 'Filter
|
|
205
|
+
description: 'Filter forums by community area. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
199
206
|
},
|
|
200
207
|
{
|
|
201
208
|
displayName: 'Forum Name or ID',
|
|
202
209
|
name: 'forumId',
|
|
203
210
|
type: 'options',
|
|
204
|
-
typeOptions: {
|
|
211
|
+
typeOptions: {
|
|
212
|
+
loadOptionsMethod: 'community_getForums',
|
|
213
|
+
loadOptionsDependsOn: ['areaId'],
|
|
214
|
+
},
|
|
205
215
|
displayOptions: {
|
|
206
|
-
show: { resource: ['community'], operation: ['getCommunityPosts'] },
|
|
216
|
+
show: { resource: ['community'], operation: ['getCommunityPosts', 'createCommunityPost'] },
|
|
207
217
|
},
|
|
208
218
|
default: '',
|
|
209
|
-
placeholder: 'Select Forum
|
|
210
|
-
description: '
|
|
219
|
+
placeholder: 'Select Forum',
|
|
220
|
+
description: 'The forum in which the post should be published. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
displayName: 'Post Title',
|
|
224
|
+
name: 'postTitle',
|
|
225
|
+
type: 'string',
|
|
226
|
+
displayOptions: { show: { resource: ['community'], operation: ['createCommunityPost'] } },
|
|
227
|
+
default: '',
|
|
228
|
+
description: 'Title of the post. Only applicable to discussions.',
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
displayName: 'Answer to Post ID',
|
|
232
|
+
name: 'answerToPostId',
|
|
233
|
+
type: 'string',
|
|
234
|
+
displayOptions: { show: { resource: ['community'], operation: ['createCommunityPost'] } },
|
|
235
|
+
default: '',
|
|
236
|
+
description: 'If set, this post is created as an answer to another post. Only applicable to discussions.',
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
displayName: 'Content Format',
|
|
240
|
+
name: 'contentFormat',
|
|
241
|
+
type: 'options',
|
|
242
|
+
displayOptions: { show: { resource: ['community'], operation: ['createCommunityPost'] } },
|
|
243
|
+
options: [
|
|
244
|
+
{ name: 'Text or HTML', value: 'string' },
|
|
245
|
+
{ name: 'JSON Array', value: 'json' },
|
|
246
|
+
],
|
|
247
|
+
default: 'string',
|
|
248
|
+
description: 'Format to send for the post content',
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
displayName: 'Content',
|
|
252
|
+
name: 'content',
|
|
253
|
+
type: 'string',
|
|
254
|
+
typeOptions: { rows: 6 },
|
|
255
|
+
displayOptions: {
|
|
256
|
+
show: { resource: ['community'], operation: ['createCommunityPost'], contentFormat: ['string'] },
|
|
257
|
+
},
|
|
258
|
+
default: '',
|
|
259
|
+
required: true,
|
|
260
|
+
description: 'Content of the post. May be plain text or HTML.',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
displayName: 'Content JSON',
|
|
264
|
+
name: 'contentJson',
|
|
265
|
+
type: 'json',
|
|
266
|
+
typeOptions: { rows: 6 },
|
|
267
|
+
displayOptions: {
|
|
268
|
+
show: { resource: ['community'], operation: ['createCommunityPost'], contentFormat: ['json'] },
|
|
269
|
+
},
|
|
270
|
+
default: '[]',
|
|
271
|
+
required: true,
|
|
272
|
+
description: 'Content of the post as a JSON array of objects, for example Slate content',
|
|
211
273
|
},
|
|
212
274
|
{
|
|
213
275
|
displayName: 'Order',
|
|
@@ -57,6 +57,50 @@ const removeBadgesFromUser = async (ctx, i) => {
|
|
|
57
57
|
const body = { userId: memberId, badgeIds };
|
|
58
58
|
return await shared_1.lsRequest.call(ctx, 'DELETE', '/community/badges/user', { body });
|
|
59
59
|
};
|
|
60
|
+
const createCommunityPost = async (ctx, i) => {
|
|
61
|
+
const authorUserId = String(ctx.getNodeParameter('authorUserId', i, '') || '').trim();
|
|
62
|
+
const forumId = String(ctx.getNodeParameter('forumId', i, '') || '').trim();
|
|
63
|
+
const postTitle = String(ctx.getNodeParameter('postTitle', i, '') || '').trim();
|
|
64
|
+
const answerToPostId = String(ctx.getNodeParameter('answerToPostId', i, '') || '').trim();
|
|
65
|
+
const contentFormat = ctx.getNodeParameter('contentFormat', i, 'string');
|
|
66
|
+
if (!authorUserId) {
|
|
67
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), 'Please provide authorUserId.');
|
|
68
|
+
}
|
|
69
|
+
if (!forumId) {
|
|
70
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), 'Please provide a forum ID.');
|
|
71
|
+
}
|
|
72
|
+
let content;
|
|
73
|
+
if (contentFormat === 'json') {
|
|
74
|
+
const contentJson = ctx.getNodeParameter('contentJson', i, '[]');
|
|
75
|
+
try {
|
|
76
|
+
content = JSON.parse(contentJson);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `Invalid JSON in content: ${String(err)}`);
|
|
80
|
+
}
|
|
81
|
+
if (!Array.isArray(content)) {
|
|
82
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), 'Content JSON must be an array of objects.');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
content = String(ctx.getNodeParameter('content', i, '') || '').trim();
|
|
87
|
+
if (!content) {
|
|
88
|
+
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), 'The post content cannot be empty.');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const body = {
|
|
92
|
+
authorUserId,
|
|
93
|
+
forumId,
|
|
94
|
+
content,
|
|
95
|
+
};
|
|
96
|
+
if (postTitle) {
|
|
97
|
+
body.postTitle = postTitle;
|
|
98
|
+
}
|
|
99
|
+
if (answerToPostId) {
|
|
100
|
+
body.answerToPostId = answerToPostId;
|
|
101
|
+
}
|
|
102
|
+
return shared_1.lsRequest.call(ctx, 'POST', '/community/posts', { body });
|
|
103
|
+
};
|
|
60
104
|
const commentOnPost = async (ctx, i) => {
|
|
61
105
|
const postId = String(ctx.getNodeParameter('postId', i, '') || '').trim();
|
|
62
106
|
const authorUserId = String(ctx.getNodeParameter('authorUserId', i, '') || '').trim();
|
|
@@ -89,6 +133,7 @@ exports.communityHandlers = {
|
|
|
89
133
|
getBadges,
|
|
90
134
|
assignBadgesToUser,
|
|
91
135
|
removeBadgesFromUser,
|
|
136
|
+
createCommunityPost,
|
|
92
137
|
commentOnPost: exports.commentOnPost,
|
|
93
138
|
getCommunityPosts,
|
|
94
139
|
};
|