n8n-nodes-base 0.212.0 → 0.212.1
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.
- package/dist/credentials/Aws.credentials.d.ts +1 -1
- package/dist/credentials/SlackOAuth2Api.credentials.js +6 -0
- package/dist/credentials/SlackOAuth2Api.credentials.js.map +1 -1
- package/dist/known/credentials.json +4 -2
- package/dist/nodes/BambooHr/v1/actions/Interfaces.d.ts +10 -10
- package/dist/nodes/Bitwarden/descriptions/CollectionDescription.d.ts +1 -1
- package/dist/nodes/Bitwarden/descriptions/GroupDescription.d.ts +3 -3
- package/dist/nodes/Bitwarden/descriptions/MemberDescription.d.ts +3 -3
- package/dist/nodes/Code/utils.d.ts +1 -1
- package/dist/nodes/CompareDatasets/GenericFunctions.d.ts +1 -1
- package/dist/nodes/ERPNext/utils.d.ts +2 -2
- package/dist/nodes/Google/Analytics/v2/actions/node.type.d.ts +5 -5
- package/dist/nodes/Google/Sheet/v1/GoogleSheet.d.ts +2 -2
- package/dist/nodes/Google/Sheet/v2/helpers/GoogleSheets.types.d.ts +14 -14
- package/dist/nodes/Html/types.d.ts +1 -1
- package/dist/nodes/HttpRequest/GenericFunctions.d.ts +1 -1
- package/dist/nodes/Jenkins/Jenkins.node.d.ts +1 -1
- package/dist/nodes/Mattermost/v1/actions/Interfaces.d.ts +10 -10
- package/dist/nodes/Merge/v2/GenericFunctions.d.ts +9 -9
- package/dist/nodes/MongoDb/mongoDb.types.d.ts +2 -2
- package/dist/nodes/Notion/GenericFunctions.d.ts +1 -1
- package/dist/nodes/Odoo/GenericFunctions.d.ts +1 -1
- package/dist/nodes/SeaTable/Interfaces.d.ts +1 -1
- package/dist/nodes/SeaTable/Schema.d.ts +1 -1
- package/dist/nodes/SendGrid/MailDescription.d.ts +2 -2
- package/dist/nodes/Slack/Slack.node.d.ts +3 -12
- package/dist/nodes/Slack/Slack.node.js +9 -997
- package/dist/nodes/Slack/Slack.node.js.map +1 -1
- package/dist/nodes/Slack/{ChannelDescription.d.ts → V1/ChannelDescription.d.ts} +0 -0
- package/dist/nodes/Slack/{ChannelDescription.js → V1/ChannelDescription.js} +0 -0
- package/dist/nodes/Slack/V1/ChannelDescription.js.map +1 -0
- package/dist/nodes/Slack/{FileDescription.d.ts → V1/FileDescription.d.ts} +0 -0
- package/dist/nodes/Slack/{FileDescription.js → V1/FileDescription.js} +0 -0
- package/dist/nodes/Slack/V1/FileDescription.js.map +1 -0
- package/dist/nodes/Slack/{GenericFunctions.d.ts → V1/GenericFunctions.d.ts} +0 -0
- package/dist/nodes/Slack/{GenericFunctions.js → V1/GenericFunctions.js} +0 -0
- package/dist/nodes/Slack/V1/GenericFunctions.js.map +1 -0
- package/dist/nodes/Slack/{MessageDescription.d.ts → V1/MessageDescription.d.ts} +0 -0
- package/dist/nodes/Slack/{MessageDescription.js → V1/MessageDescription.js} +0 -0
- package/dist/nodes/Slack/V1/MessageDescription.js.map +1 -0
- package/dist/nodes/Slack/{MessageInterface.d.ts → V1/MessageInterface.d.ts} +0 -0
- package/dist/nodes/Slack/{MessageInterface.js → V1/MessageInterface.js} +0 -0
- package/dist/nodes/Slack/V1/MessageInterface.js.map +1 -0
- package/dist/nodes/Slack/{ReactionDescription.d.ts → V1/ReactionDescription.d.ts} +0 -0
- package/dist/nodes/Slack/{ReactionDescription.js → V1/ReactionDescription.js} +0 -0
- package/dist/nodes/Slack/V1/ReactionDescription.js.map +1 -0
- package/dist/nodes/Slack/V1/SlackV1.node.d.ts +14 -0
- package/dist/nodes/Slack/V1/SlackV1.node.js +1012 -0
- package/dist/nodes/Slack/V1/SlackV1.node.js.map +1 -0
- package/dist/nodes/Slack/{StarDescription.d.ts → V1/StarDescription.d.ts} +0 -0
- package/dist/nodes/Slack/{StarDescription.js → V1/StarDescription.js} +0 -0
- package/dist/nodes/Slack/V1/StarDescription.js.map +1 -0
- package/dist/nodes/Slack/{UserDescription.d.ts → V1/UserDescription.d.ts} +0 -0
- package/dist/nodes/Slack/{UserDescription.js → V1/UserDescription.js} +0 -0
- package/dist/nodes/Slack/V1/UserDescription.js.map +1 -0
- package/dist/nodes/Slack/{UserGroupDescription.d.ts → V1/UserGroupDescription.d.ts} +0 -0
- package/dist/nodes/Slack/{UserGroupDescription.js → V1/UserGroupDescription.js} +0 -0
- package/dist/nodes/Slack/V1/UserGroupDescription.js.map +1 -0
- package/dist/nodes/Slack/{UserProfileDescription.d.ts → V1/UserProfileDescription.d.ts} +0 -0
- package/dist/nodes/Slack/{UserProfileDescription.js → V1/UserProfileDescription.js} +0 -0
- package/dist/nodes/Slack/V1/UserProfileDescription.js.map +1 -0
- package/dist/nodes/Slack/V2/ChannelDescription.d.ts +3 -0
- package/dist/nodes/Slack/V2/ChannelDescription.js +1420 -0
- package/dist/nodes/Slack/V2/ChannelDescription.js.map +1 -0
- package/dist/nodes/Slack/V2/FileDescription.d.ts +3 -0
- package/dist/nodes/Slack/V2/FileDescription.js +270 -0
- package/dist/nodes/Slack/V2/FileDescription.js.map +1 -0
- package/dist/nodes/Slack/V2/GenericFunctions.d.ts +5 -0
- package/dist/nodes/Slack/V2/GenericFunctions.js +95 -0
- package/dist/nodes/Slack/V2/GenericFunctions.js.map +1 -0
- package/dist/nodes/Slack/V2/MessageDescription.d.ts +3 -0
- package/dist/nodes/Slack/V2/MessageDescription.js +1109 -0
- package/dist/nodes/Slack/V2/MessageDescription.js.map +1 -0
- package/dist/nodes/Slack/V2/MessageInterface.d.ts +5 -0
- package/dist/nodes/Slack/V2/MessageInterface.js +3 -0
- package/dist/nodes/Slack/V2/MessageInterface.js.map +1 -0
- package/dist/nodes/Slack/V2/ReactionDescription.d.ts +3 -0
- package/dist/nodes/Slack/V2/ReactionDescription.js +131 -0
- package/dist/nodes/Slack/V2/ReactionDescription.js.map +1 -0
- package/dist/nodes/Slack/V2/SlackV2.node.d.ts +19 -0
- package/dist/nodes/Slack/V2/SlackV2.node.js +908 -0
- package/dist/nodes/Slack/V2/SlackV2.node.js.map +1 -0
- package/dist/nodes/Slack/V2/StarDescription.d.ts +3 -0
- package/dist/nodes/Slack/V2/StarDescription.js +257 -0
- package/dist/nodes/Slack/V2/StarDescription.js.map +1 -0
- package/dist/nodes/Slack/V2/UserDescription.d.ts +3 -0
- package/dist/nodes/Slack/V2/UserDescription.js +281 -0
- package/dist/nodes/Slack/V2/UserDescription.js.map +1 -0
- package/dist/nodes/Slack/V2/UserGroupDescription.d.ts +3 -0
- package/dist/nodes/Slack/V2/UserGroupDescription.js +313 -0
- package/dist/nodes/Slack/V2/UserGroupDescription.js.map +1 -0
- package/dist/nodes/Supabase/Supabase.node.d.ts +1 -1
- package/dist/nodes/SyncroMSP/v1/actions/Interfaces.d.ts +10 -10
- package/dist/nodes/TheHive/QueryFunctions.d.ts +1 -1
- package/dist/nodes/Todoist/GenericFunctions.d.ts +1 -1
- package/dist/nodes/Wise/GenericFunctions.d.ts +6 -6
- package/dist/nodes/WooCommerce/GenericFunctions.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/credentials.json +1 -1
- package/dist/types/nodes.json +3 -2
- package/package.json +1 -1
- package/dist/nodes/Slack/ChannelDescription.js.map +0 -1
- package/dist/nodes/Slack/FileDescription.js.map +0 -1
- package/dist/nodes/Slack/GenericFunctions.js.map +0 -1
- package/dist/nodes/Slack/MessageDescription.js.map +0 -1
- package/dist/nodes/Slack/MessageInterface.js.map +0 -1
- package/dist/nodes/Slack/ReactionDescription.js.map +0 -1
- package/dist/nodes/Slack/StarDescription.js.map +0 -1
- package/dist/nodes/Slack/UserDescription.js.map +0 -1
- package/dist/nodes/Slack/UserGroupDescription.js.map +0 -1
- package/dist/nodes/Slack/UserProfileDescription.js.map +0 -1
|
@@ -0,0 +1,1012 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SlackV1 = void 0;
|
|
7
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
8
|
+
const ChannelDescription_1 = require("./ChannelDescription");
|
|
9
|
+
const MessageDescription_1 = require("./MessageDescription");
|
|
10
|
+
const StarDescription_1 = require("./StarDescription");
|
|
11
|
+
const FileDescription_1 = require("./FileDescription");
|
|
12
|
+
const ReactionDescription_1 = require("./ReactionDescription");
|
|
13
|
+
const UserGroupDescription_1 = require("./UserGroupDescription");
|
|
14
|
+
const UserDescription_1 = require("./UserDescription");
|
|
15
|
+
const UserProfileDescription_1 = require("./UserProfileDescription");
|
|
16
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
17
|
+
const moment_1 = __importDefault(require("moment"));
|
|
18
|
+
class SlackV1 {
|
|
19
|
+
constructor(baseDescription) {
|
|
20
|
+
this.methods = {
|
|
21
|
+
loadOptions: {
|
|
22
|
+
async getUsers() {
|
|
23
|
+
const returnData = [];
|
|
24
|
+
const users = await GenericFunctions_1.slackApiRequestAllItems.call(this, 'members', 'GET', '/users.list');
|
|
25
|
+
for (const user of users) {
|
|
26
|
+
const userName = user.name;
|
|
27
|
+
const userId = user.id;
|
|
28
|
+
returnData.push({
|
|
29
|
+
name: userName,
|
|
30
|
+
value: userId,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
returnData.sort((a, b) => {
|
|
34
|
+
if (a.name < b.name) {
|
|
35
|
+
return -1;
|
|
36
|
+
}
|
|
37
|
+
if (a.name > b.name) {
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
return 0;
|
|
41
|
+
});
|
|
42
|
+
return returnData;
|
|
43
|
+
},
|
|
44
|
+
async getChannels() {
|
|
45
|
+
const returnData = [];
|
|
46
|
+
const qs = { types: 'public_channel,private_channel', limit: 1000 };
|
|
47
|
+
const channels = await GenericFunctions_1.slackApiRequestAllItems.call(this, 'channels', 'GET', '/conversations.list', {}, qs);
|
|
48
|
+
for (const channel of channels) {
|
|
49
|
+
const channelName = channel.name;
|
|
50
|
+
const channelId = channel.id;
|
|
51
|
+
returnData.push({
|
|
52
|
+
name: channelName,
|
|
53
|
+
value: channelId,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
returnData.sort((a, b) => {
|
|
57
|
+
if (a.name < b.name) {
|
|
58
|
+
return -1;
|
|
59
|
+
}
|
|
60
|
+
if (a.name > b.name) {
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
return 0;
|
|
64
|
+
});
|
|
65
|
+
return returnData;
|
|
66
|
+
},
|
|
67
|
+
async getTeamFields() {
|
|
68
|
+
const returnData = [];
|
|
69
|
+
const { profile: { fields }, } = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/team.profile.get');
|
|
70
|
+
for (const field of fields) {
|
|
71
|
+
const fieldName = field.label;
|
|
72
|
+
const fieldId = field.id;
|
|
73
|
+
returnData.push({
|
|
74
|
+
name: fieldName,
|
|
75
|
+
value: fieldId,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return returnData;
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
this.description = {
|
|
83
|
+
...baseDescription,
|
|
84
|
+
version: 1,
|
|
85
|
+
defaults: {
|
|
86
|
+
name: 'Slack',
|
|
87
|
+
},
|
|
88
|
+
inputs: ['main'],
|
|
89
|
+
outputs: ['main'],
|
|
90
|
+
credentials: [
|
|
91
|
+
{
|
|
92
|
+
name: 'slackApi',
|
|
93
|
+
required: true,
|
|
94
|
+
displayOptions: {
|
|
95
|
+
show: {
|
|
96
|
+
authentication: ['accessToken'],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'slackOAuth2Api',
|
|
102
|
+
required: true,
|
|
103
|
+
displayOptions: {
|
|
104
|
+
show: {
|
|
105
|
+
authentication: ['oAuth2'],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
properties: [
|
|
111
|
+
{
|
|
112
|
+
displayName: 'Authentication',
|
|
113
|
+
name: 'authentication',
|
|
114
|
+
type: 'options',
|
|
115
|
+
options: [
|
|
116
|
+
{
|
|
117
|
+
name: 'Access Token',
|
|
118
|
+
value: 'accessToken',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'OAuth2',
|
|
122
|
+
value: 'oAuth2',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
default: 'accessToken',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
displayName: 'Resource',
|
|
129
|
+
name: 'resource',
|
|
130
|
+
type: 'options',
|
|
131
|
+
noDataExpression: true,
|
|
132
|
+
options: [
|
|
133
|
+
{
|
|
134
|
+
name: 'Channel',
|
|
135
|
+
value: 'channel',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'File',
|
|
139
|
+
value: 'file',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'Message',
|
|
143
|
+
value: 'message',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'Reaction',
|
|
147
|
+
value: 'reaction',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'Star',
|
|
151
|
+
value: 'star',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'User',
|
|
155
|
+
value: 'user',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'User Group',
|
|
159
|
+
value: 'userGroup',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'User Profile',
|
|
163
|
+
value: 'userProfile',
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
default: 'message',
|
|
167
|
+
},
|
|
168
|
+
...ChannelDescription_1.channelOperations,
|
|
169
|
+
...ChannelDescription_1.channelFields,
|
|
170
|
+
...MessageDescription_1.messageOperations,
|
|
171
|
+
...MessageDescription_1.messageFields,
|
|
172
|
+
...StarDescription_1.starOperations,
|
|
173
|
+
...StarDescription_1.starFields,
|
|
174
|
+
...FileDescription_1.fileOperations,
|
|
175
|
+
...FileDescription_1.fileFields,
|
|
176
|
+
...ReactionDescription_1.reactionOperations,
|
|
177
|
+
...ReactionDescription_1.reactionFields,
|
|
178
|
+
...UserDescription_1.userOperations,
|
|
179
|
+
...UserDescription_1.userFields,
|
|
180
|
+
...UserGroupDescription_1.userGroupOperations,
|
|
181
|
+
...UserGroupDescription_1.userGroupFields,
|
|
182
|
+
...UserProfileDescription_1.userProfileOperations,
|
|
183
|
+
...UserProfileDescription_1.userProfileFields,
|
|
184
|
+
],
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
async execute() {
|
|
188
|
+
const items = this.getInputData();
|
|
189
|
+
const returnData = [];
|
|
190
|
+
const length = items.length;
|
|
191
|
+
let qs;
|
|
192
|
+
let responseData;
|
|
193
|
+
const authentication = this.getNodeParameter('authentication', 0);
|
|
194
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
195
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
196
|
+
for (let i = 0; i < length; i++) {
|
|
197
|
+
try {
|
|
198
|
+
responseData = {
|
|
199
|
+
error: 'Resource ' + resource + ' / operation ' + operation + ' not found!',
|
|
200
|
+
};
|
|
201
|
+
qs = {};
|
|
202
|
+
if (resource === 'channel') {
|
|
203
|
+
if (operation === 'archive') {
|
|
204
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
205
|
+
const body = {
|
|
206
|
+
channel,
|
|
207
|
+
};
|
|
208
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.archive', body, qs);
|
|
209
|
+
}
|
|
210
|
+
if (operation === 'close') {
|
|
211
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
212
|
+
const body = {
|
|
213
|
+
channel,
|
|
214
|
+
};
|
|
215
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.close', body, qs);
|
|
216
|
+
}
|
|
217
|
+
if (operation === 'create') {
|
|
218
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
219
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
220
|
+
const body = {
|
|
221
|
+
name: channel,
|
|
222
|
+
};
|
|
223
|
+
if (additionalFields.isPrivate) {
|
|
224
|
+
body.is_private = additionalFields.isPrivate;
|
|
225
|
+
}
|
|
226
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.create', body, qs);
|
|
227
|
+
responseData = responseData.channel;
|
|
228
|
+
}
|
|
229
|
+
if (operation === 'kick') {
|
|
230
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
231
|
+
const userId = this.getNodeParameter('userId', i);
|
|
232
|
+
const body = {
|
|
233
|
+
channel,
|
|
234
|
+
user: userId,
|
|
235
|
+
};
|
|
236
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.kick', body, qs);
|
|
237
|
+
}
|
|
238
|
+
if (operation === 'join') {
|
|
239
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
240
|
+
const body = {
|
|
241
|
+
channel,
|
|
242
|
+
};
|
|
243
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.join', body, qs);
|
|
244
|
+
responseData = responseData.channel;
|
|
245
|
+
}
|
|
246
|
+
if (operation === 'get') {
|
|
247
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
248
|
+
qs.channel = channel;
|
|
249
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.info', {}, qs);
|
|
250
|
+
responseData = responseData.channel;
|
|
251
|
+
}
|
|
252
|
+
if (operation === 'getAll') {
|
|
253
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
254
|
+
const filters = this.getNodeParameter('filters', i);
|
|
255
|
+
if (filters.types) {
|
|
256
|
+
qs.types = filters.types.join(',');
|
|
257
|
+
}
|
|
258
|
+
if (filters.excludeArchived) {
|
|
259
|
+
qs.exclude_archived = filters.excludeArchived;
|
|
260
|
+
}
|
|
261
|
+
if (returnAll) {
|
|
262
|
+
responseData = await GenericFunctions_1.slackApiRequestAllItems.call(this, 'channels', 'GET', '/conversations.list', {}, qs);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
qs.limit = this.getNodeParameter('limit', i);
|
|
266
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/conversations.list', {}, qs);
|
|
267
|
+
responseData = responseData.channels;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (operation === 'history') {
|
|
271
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
272
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
273
|
+
const filters = this.getNodeParameter('filters', i);
|
|
274
|
+
qs.channel = channel;
|
|
275
|
+
if (filters.inclusive) {
|
|
276
|
+
qs.inclusive = filters.inclusive;
|
|
277
|
+
}
|
|
278
|
+
if (filters.latest) {
|
|
279
|
+
qs.latest = new Date(filters.latest).getTime() / 1000;
|
|
280
|
+
}
|
|
281
|
+
if (filters.oldest) {
|
|
282
|
+
qs.oldest = new Date(filters.oldest).getTime() / 1000;
|
|
283
|
+
}
|
|
284
|
+
if (returnAll) {
|
|
285
|
+
responseData = await GenericFunctions_1.slackApiRequestAllItems.call(this, 'messages', 'GET', '/conversations.history', {}, qs);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
qs.limit = this.getNodeParameter('limit', i);
|
|
289
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/conversations.history', {}, qs);
|
|
290
|
+
responseData = responseData.messages;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (operation === 'invite') {
|
|
294
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
295
|
+
const userIds = this.getNodeParameter('userIds', i).join(',');
|
|
296
|
+
const body = {
|
|
297
|
+
channel,
|
|
298
|
+
users: userIds,
|
|
299
|
+
};
|
|
300
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.invite', body, qs);
|
|
301
|
+
responseData = responseData.channel;
|
|
302
|
+
}
|
|
303
|
+
if (operation === 'leave') {
|
|
304
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
305
|
+
const body = {
|
|
306
|
+
channel,
|
|
307
|
+
};
|
|
308
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.leave', body, qs);
|
|
309
|
+
}
|
|
310
|
+
if (operation === 'member') {
|
|
311
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
312
|
+
const resolveData = this.getNodeParameter('resolveData', 0);
|
|
313
|
+
qs.channel = this.getNodeParameter('channelId', i);
|
|
314
|
+
if (returnAll) {
|
|
315
|
+
responseData = await GenericFunctions_1.slackApiRequestAllItems.call(this, 'members', 'GET', '/conversations.members', {}, qs);
|
|
316
|
+
responseData = responseData.map((member) => ({ member }));
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
qs.limit = this.getNodeParameter('limit', i);
|
|
320
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/conversations.members', {}, qs);
|
|
321
|
+
responseData = responseData.members.map((member) => ({ member }));
|
|
322
|
+
}
|
|
323
|
+
if (resolveData) {
|
|
324
|
+
const data = [];
|
|
325
|
+
for (const { member } of responseData) {
|
|
326
|
+
const { user } = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/users.info', {}, { user: member });
|
|
327
|
+
data.push(user);
|
|
328
|
+
}
|
|
329
|
+
responseData = data;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (operation === 'open') {
|
|
333
|
+
const options = this.getNodeParameter('options', i);
|
|
334
|
+
const body = {};
|
|
335
|
+
if (options.channelId) {
|
|
336
|
+
body.channel = options.channelId;
|
|
337
|
+
}
|
|
338
|
+
if (options.returnIm) {
|
|
339
|
+
body.return_im = options.returnIm;
|
|
340
|
+
}
|
|
341
|
+
if (options.users) {
|
|
342
|
+
body.users = options.users.join(',');
|
|
343
|
+
}
|
|
344
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.open', body, qs);
|
|
345
|
+
responseData = responseData.channel;
|
|
346
|
+
}
|
|
347
|
+
if (operation === 'rename') {
|
|
348
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
349
|
+
const name = this.getNodeParameter('name', i);
|
|
350
|
+
const body = {
|
|
351
|
+
channel,
|
|
352
|
+
name,
|
|
353
|
+
};
|
|
354
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.rename', body, qs);
|
|
355
|
+
responseData = responseData.channel;
|
|
356
|
+
}
|
|
357
|
+
if (operation === 'replies') {
|
|
358
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
359
|
+
const ts = this.getNodeParameter('ts', i);
|
|
360
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
361
|
+
const filters = this.getNodeParameter('filters', i);
|
|
362
|
+
qs.channel = channel;
|
|
363
|
+
qs.ts = ts;
|
|
364
|
+
if (filters.inclusive) {
|
|
365
|
+
qs.inclusive = filters.inclusive;
|
|
366
|
+
}
|
|
367
|
+
if (filters.latest) {
|
|
368
|
+
qs.latest = new Date(filters.latest).getTime() / 1000;
|
|
369
|
+
}
|
|
370
|
+
if (filters.oldest) {
|
|
371
|
+
qs.oldest = new Date(filters.oldest).getTime() / 1000;
|
|
372
|
+
}
|
|
373
|
+
if (returnAll) {
|
|
374
|
+
responseData = await GenericFunctions_1.slackApiRequestAllItems.call(this, 'messages', 'GET', '/conversations.replies', {}, qs);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
qs.limit = this.getNodeParameter('limit', i);
|
|
378
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/conversations.replies', {}, qs);
|
|
379
|
+
responseData = responseData.messages;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (operation === 'setPurpose') {
|
|
383
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
384
|
+
const purpose = this.getNodeParameter('purpose', i);
|
|
385
|
+
const body = {
|
|
386
|
+
channel,
|
|
387
|
+
purpose,
|
|
388
|
+
};
|
|
389
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.setPurpose', body, qs);
|
|
390
|
+
responseData = responseData.channel;
|
|
391
|
+
}
|
|
392
|
+
if (operation === 'setTopic') {
|
|
393
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
394
|
+
const topic = this.getNodeParameter('topic', i);
|
|
395
|
+
const body = {
|
|
396
|
+
channel,
|
|
397
|
+
topic,
|
|
398
|
+
};
|
|
399
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.setTopic', body, qs);
|
|
400
|
+
responseData = responseData.channel;
|
|
401
|
+
}
|
|
402
|
+
if (operation === 'unarchive') {
|
|
403
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
404
|
+
const body = {
|
|
405
|
+
channel,
|
|
406
|
+
};
|
|
407
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/conversations.unarchive', body, qs);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (resource === 'message') {
|
|
411
|
+
if (['post', 'postEphemeral'].includes(operation)) {
|
|
412
|
+
const channel = this.getNodeParameter('channel', i);
|
|
413
|
+
const { sendAsUser } = this.getNodeParameter('otherOptions', i);
|
|
414
|
+
const text = this.getNodeParameter('text', i);
|
|
415
|
+
const body = {
|
|
416
|
+
channel,
|
|
417
|
+
text,
|
|
418
|
+
};
|
|
419
|
+
let action = 'postMessage';
|
|
420
|
+
if (operation === 'postEphemeral') {
|
|
421
|
+
body.user = this.getNodeParameter('user', i);
|
|
422
|
+
action = 'postEphemeral';
|
|
423
|
+
}
|
|
424
|
+
const jsonParameters = this.getNodeParameter('jsonParameters', i);
|
|
425
|
+
if (authentication === 'accessToken' && sendAsUser !== '') {
|
|
426
|
+
body.username = sendAsUser;
|
|
427
|
+
}
|
|
428
|
+
if (!jsonParameters) {
|
|
429
|
+
const attachments = this.getNodeParameter('attachments', i, []);
|
|
430
|
+
const blocksUi = this.getNodeParameter('blocksUi', i, [])
|
|
431
|
+
.blocksValues;
|
|
432
|
+
for (const attachment of attachments) {
|
|
433
|
+
if (attachment.fields !== undefined) {
|
|
434
|
+
if (attachment.fields.item !== undefined) {
|
|
435
|
+
attachment.fields = attachment.fields.item;
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
delete attachment.fields;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
body.attachments = attachments;
|
|
443
|
+
if (blocksUi) {
|
|
444
|
+
const blocks = [];
|
|
445
|
+
for (const blockUi of blocksUi) {
|
|
446
|
+
const block = {};
|
|
447
|
+
const elements = [];
|
|
448
|
+
block.block_id = blockUi.blockId;
|
|
449
|
+
block.type = blockUi.type;
|
|
450
|
+
if (block.type === 'actions') {
|
|
451
|
+
const elementsUi = blockUi.elementsUi
|
|
452
|
+
.elementsValues;
|
|
453
|
+
if (elementsUi) {
|
|
454
|
+
for (const elementUi of elementsUi) {
|
|
455
|
+
const element = {};
|
|
456
|
+
if (elementUi.actionId === '') {
|
|
457
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Action ID must be set', {
|
|
458
|
+
itemIndex: i,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
if (elementUi.text === '') {
|
|
462
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Text must be set', {
|
|
463
|
+
itemIndex: i,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
element.action_id = elementUi.actionId;
|
|
467
|
+
element.type = elementUi.type;
|
|
468
|
+
element.text = {
|
|
469
|
+
text: elementUi.text,
|
|
470
|
+
type: 'plain_text',
|
|
471
|
+
emoji: elementUi.emoji,
|
|
472
|
+
};
|
|
473
|
+
if (elementUi.url) {
|
|
474
|
+
element.url = elementUi.url;
|
|
475
|
+
}
|
|
476
|
+
if (elementUi.value) {
|
|
477
|
+
element.value = elementUi.value;
|
|
478
|
+
}
|
|
479
|
+
if (elementUi.style !== 'default') {
|
|
480
|
+
element.style = elementUi.style;
|
|
481
|
+
}
|
|
482
|
+
const confirmUi = elementUi.confirmUi
|
|
483
|
+
.confirmValue;
|
|
484
|
+
if (confirmUi) {
|
|
485
|
+
const confirm = {};
|
|
486
|
+
const titleUi = confirmUi.titleUi
|
|
487
|
+
.titleValue;
|
|
488
|
+
const textUi = confirmUi.textUi.textValue;
|
|
489
|
+
const confirmTextUi = confirmUi.confirmTextUi
|
|
490
|
+
.confirmValue;
|
|
491
|
+
const denyUi = confirmUi.denyUi.denyValue;
|
|
492
|
+
const style = confirmUi.style;
|
|
493
|
+
if (titleUi) {
|
|
494
|
+
confirm.title = {
|
|
495
|
+
type: 'plain_text',
|
|
496
|
+
text: titleUi.text,
|
|
497
|
+
emoji: titleUi.emoji,
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
if (textUi) {
|
|
501
|
+
confirm.text = {
|
|
502
|
+
type: 'plain_text',
|
|
503
|
+
text: textUi.text,
|
|
504
|
+
emoji: textUi.emoji,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
if (confirmTextUi) {
|
|
508
|
+
confirm.confirm = {
|
|
509
|
+
type: 'plain_text',
|
|
510
|
+
text: confirmTextUi.text,
|
|
511
|
+
emoji: confirmTextUi.emoji,
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
if (denyUi) {
|
|
515
|
+
confirm.deny = {
|
|
516
|
+
type: 'plain_text',
|
|
517
|
+
text: denyUi.text,
|
|
518
|
+
emoji: denyUi.emoji,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
if (style !== 'default') {
|
|
522
|
+
confirm.style = style;
|
|
523
|
+
}
|
|
524
|
+
element.confirm = confirm;
|
|
525
|
+
}
|
|
526
|
+
elements.push(element);
|
|
527
|
+
}
|
|
528
|
+
block.elements = elements;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
else if (block.type === 'section') {
|
|
532
|
+
const textUi = blockUi.textUi.textValue;
|
|
533
|
+
if (textUi) {
|
|
534
|
+
const text = {};
|
|
535
|
+
if (textUi.type === 'plainText') {
|
|
536
|
+
text.type = 'plain_text';
|
|
537
|
+
text.emoji = textUi.emoji;
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
text.type = 'mrkdwn';
|
|
541
|
+
text.verbatim = textUi.verbatim;
|
|
542
|
+
}
|
|
543
|
+
text.text = textUi.text;
|
|
544
|
+
block.text = text;
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Property text must be defined', { itemIndex: i });
|
|
548
|
+
}
|
|
549
|
+
const fieldsUi = blockUi.fieldsUi
|
|
550
|
+
.fieldsValues;
|
|
551
|
+
if (fieldsUi) {
|
|
552
|
+
const fields = [];
|
|
553
|
+
for (const fieldUi of fieldsUi) {
|
|
554
|
+
const field = {};
|
|
555
|
+
if (fieldUi.type === 'plainText') {
|
|
556
|
+
field.type = 'plain_text';
|
|
557
|
+
field.emoji = fieldUi.emoji;
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
field.type = 'mrkdwn';
|
|
561
|
+
field.verbatim = fieldUi.verbatim;
|
|
562
|
+
}
|
|
563
|
+
field.text = fieldUi.text;
|
|
564
|
+
fields.push(field);
|
|
565
|
+
}
|
|
566
|
+
if (fields.length > 0) {
|
|
567
|
+
block.fields = fields;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
const accessoryUi = blockUi.accessoryUi
|
|
571
|
+
.accessoriesValues;
|
|
572
|
+
if (accessoryUi) {
|
|
573
|
+
const accessory = {};
|
|
574
|
+
if (accessoryUi.type === 'button') {
|
|
575
|
+
accessory.type = 'button';
|
|
576
|
+
accessory.text = {
|
|
577
|
+
text: accessoryUi.text,
|
|
578
|
+
type: 'plain_text',
|
|
579
|
+
emoji: accessoryUi.emoji,
|
|
580
|
+
};
|
|
581
|
+
if (accessoryUi.url) {
|
|
582
|
+
accessory.url = accessoryUi.url;
|
|
583
|
+
}
|
|
584
|
+
if (accessoryUi.value) {
|
|
585
|
+
accessory.value = accessoryUi.value;
|
|
586
|
+
}
|
|
587
|
+
if (accessoryUi.style !== 'default') {
|
|
588
|
+
accessory.style = accessoryUi.style;
|
|
589
|
+
}
|
|
590
|
+
const confirmUi = accessoryUi.confirmUi
|
|
591
|
+
.confirmValue;
|
|
592
|
+
if (confirmUi) {
|
|
593
|
+
const confirm = {};
|
|
594
|
+
const titleUi = confirmUi.titleUi
|
|
595
|
+
.titleValue;
|
|
596
|
+
const textUi = confirmUi.textUi.textValue;
|
|
597
|
+
const confirmTextUi = confirmUi.confirmTextUi
|
|
598
|
+
.confirmValue;
|
|
599
|
+
const denyUi = confirmUi.denyUi.denyValue;
|
|
600
|
+
const style = confirmUi.style;
|
|
601
|
+
if (titleUi) {
|
|
602
|
+
confirm.title = {
|
|
603
|
+
type: 'plain_text',
|
|
604
|
+
text: titleUi.text,
|
|
605
|
+
emoji: titleUi.emoji,
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
if (textUi) {
|
|
609
|
+
confirm.text = {
|
|
610
|
+
type: 'plain_text',
|
|
611
|
+
text: textUi.text,
|
|
612
|
+
emoji: textUi.emoji,
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
if (confirmTextUi) {
|
|
616
|
+
confirm.confirm = {
|
|
617
|
+
type: 'plain_text',
|
|
618
|
+
text: confirmTextUi.text,
|
|
619
|
+
emoji: confirmTextUi.emoji,
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
if (denyUi) {
|
|
623
|
+
confirm.deny = {
|
|
624
|
+
type: 'plain_text',
|
|
625
|
+
text: denyUi.text,
|
|
626
|
+
emoji: denyUi.emoji,
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
if (style !== 'default') {
|
|
630
|
+
confirm.style = style;
|
|
631
|
+
}
|
|
632
|
+
accessory.confirm = confirm;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
block.accessory = accessory;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
blocks.push(block);
|
|
639
|
+
}
|
|
640
|
+
body.blocks = blocks;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
const attachmentsJson = this.getNodeParameter('attachmentsJson', i, '');
|
|
645
|
+
const blocksJson = this.getNodeParameter('blocksJson', i, []);
|
|
646
|
+
if (attachmentsJson !== '' && (0, GenericFunctions_1.validateJSON)(attachmentsJson) === undefined) {
|
|
647
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Attachments it is not a valid json', {
|
|
648
|
+
itemIndex: i,
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
if (blocksJson !== '' && (0, GenericFunctions_1.validateJSON)(blocksJson) === undefined) {
|
|
652
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Blocks it is not a valid json', {
|
|
653
|
+
itemIndex: i,
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
if (attachmentsJson !== '') {
|
|
657
|
+
body.attachments = attachmentsJson;
|
|
658
|
+
}
|
|
659
|
+
if (blocksJson !== '') {
|
|
660
|
+
body.blocks = blocksJson;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
const otherOptions = this.getNodeParameter('otherOptions', i);
|
|
664
|
+
Object.assign(body, otherOptions);
|
|
665
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', `/chat.${action}`, body, qs);
|
|
666
|
+
}
|
|
667
|
+
if (operation === 'update') {
|
|
668
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
669
|
+
const text = this.getNodeParameter('text', i);
|
|
670
|
+
const ts = this.getNodeParameter('ts', i);
|
|
671
|
+
const attachments = this.getNodeParameter('attachments', i, []);
|
|
672
|
+
const body = {
|
|
673
|
+
channel,
|
|
674
|
+
text,
|
|
675
|
+
ts,
|
|
676
|
+
};
|
|
677
|
+
for (const attachment of attachments) {
|
|
678
|
+
if (attachment.fields !== undefined) {
|
|
679
|
+
if (attachment.fields.item !== undefined) {
|
|
680
|
+
attachment.fields = attachment.fields.item;
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
delete attachment.fields;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
body.attachments = attachments;
|
|
688
|
+
const jsonParameters = this.getNodeParameter('jsonParameters', i, false);
|
|
689
|
+
if (jsonParameters) {
|
|
690
|
+
const blocksJson = this.getNodeParameter('blocksJson', i, []);
|
|
691
|
+
if (blocksJson !== '' && (0, GenericFunctions_1.validateJSON)(blocksJson) === undefined) {
|
|
692
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Blocks it is not a valid json', {
|
|
693
|
+
itemIndex: i,
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
if (blocksJson !== '') {
|
|
697
|
+
body.blocks = blocksJson;
|
|
698
|
+
}
|
|
699
|
+
const attachmentsJson = this.getNodeParameter('attachmentsJson', i, '');
|
|
700
|
+
if (attachmentsJson !== '' && (0, GenericFunctions_1.validateJSON)(attachmentsJson) === undefined) {
|
|
701
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Attachments it is not a valid json', {
|
|
702
|
+
itemIndex: i,
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
if (attachmentsJson !== '') {
|
|
706
|
+
body.attachments = attachmentsJson;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
710
|
+
Object.assign(body, updateFields);
|
|
711
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/chat.update', body, qs);
|
|
712
|
+
}
|
|
713
|
+
if (operation === 'delete') {
|
|
714
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
715
|
+
const timestamp = this.getNodeParameter('timestamp', i);
|
|
716
|
+
const body = {
|
|
717
|
+
channel,
|
|
718
|
+
ts: timestamp,
|
|
719
|
+
};
|
|
720
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/chat.delete', body, qs);
|
|
721
|
+
}
|
|
722
|
+
if (operation === 'getPermalink') {
|
|
723
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
724
|
+
const timestamp = this.getNodeParameter('timestamp', i);
|
|
725
|
+
const qs = {
|
|
726
|
+
channel,
|
|
727
|
+
message_ts: timestamp,
|
|
728
|
+
};
|
|
729
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/chat.getPermalink', {}, qs);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
if (resource === 'reaction') {
|
|
733
|
+
const channel = this.getNodeParameter('channelId', i);
|
|
734
|
+
const timestamp = this.getNodeParameter('timestamp', i);
|
|
735
|
+
if (operation === 'add') {
|
|
736
|
+
const name = this.getNodeParameter('name', i);
|
|
737
|
+
const body = {
|
|
738
|
+
channel,
|
|
739
|
+
name,
|
|
740
|
+
timestamp,
|
|
741
|
+
};
|
|
742
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/reactions.add', body, qs);
|
|
743
|
+
}
|
|
744
|
+
if (operation === 'remove') {
|
|
745
|
+
const name = this.getNodeParameter('name', i);
|
|
746
|
+
const body = {
|
|
747
|
+
channel,
|
|
748
|
+
name,
|
|
749
|
+
timestamp,
|
|
750
|
+
};
|
|
751
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/reactions.remove', body, qs);
|
|
752
|
+
}
|
|
753
|
+
if (operation === 'get') {
|
|
754
|
+
qs.channel = channel;
|
|
755
|
+
qs.timestamp = timestamp;
|
|
756
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/reactions.get', {}, qs);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
if (resource === 'star') {
|
|
760
|
+
if (operation === 'add') {
|
|
761
|
+
const options = this.getNodeParameter('options', i);
|
|
762
|
+
const body = {};
|
|
763
|
+
if (options.channelId) {
|
|
764
|
+
body.channel = options.channelId;
|
|
765
|
+
}
|
|
766
|
+
if (options.fileId) {
|
|
767
|
+
body.file = options.fileId;
|
|
768
|
+
}
|
|
769
|
+
if (options.fileComment) {
|
|
770
|
+
body.file_comment = options.fileComment;
|
|
771
|
+
}
|
|
772
|
+
if (options.timestamp) {
|
|
773
|
+
body.timestamp = options.timestamp;
|
|
774
|
+
}
|
|
775
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/stars.add', body, qs);
|
|
776
|
+
}
|
|
777
|
+
if (operation === 'delete') {
|
|
778
|
+
const options = this.getNodeParameter('options', i);
|
|
779
|
+
const body = {};
|
|
780
|
+
if (options.channelId) {
|
|
781
|
+
body.channel = options.channelId;
|
|
782
|
+
}
|
|
783
|
+
if (options.fileId) {
|
|
784
|
+
body.file = options.fileId;
|
|
785
|
+
}
|
|
786
|
+
if (options.fileComment) {
|
|
787
|
+
body.file_comment = options.fileComment;
|
|
788
|
+
}
|
|
789
|
+
if (options.timestamp) {
|
|
790
|
+
body.timestamp = options.timestamp;
|
|
791
|
+
}
|
|
792
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/stars.remove', body, qs);
|
|
793
|
+
}
|
|
794
|
+
if (operation === 'getAll') {
|
|
795
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
796
|
+
if (returnAll) {
|
|
797
|
+
responseData = await GenericFunctions_1.slackApiRequestAllItems.call(this, 'items', 'GET', '/stars.list', {}, qs);
|
|
798
|
+
}
|
|
799
|
+
else {
|
|
800
|
+
qs.limit = this.getNodeParameter('limit', i);
|
|
801
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/stars.list', {}, qs);
|
|
802
|
+
responseData = responseData.items;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
if (resource === 'file') {
|
|
807
|
+
if (operation === 'upload') {
|
|
808
|
+
const options = this.getNodeParameter('options', i);
|
|
809
|
+
const binaryData = this.getNodeParameter('binaryData', i);
|
|
810
|
+
const body = {};
|
|
811
|
+
if (options.channelIds) {
|
|
812
|
+
body.channels = options.channelIds.join(',');
|
|
813
|
+
}
|
|
814
|
+
if (options.fileName) {
|
|
815
|
+
body.filename = options.fileName;
|
|
816
|
+
}
|
|
817
|
+
if (options.initialComment) {
|
|
818
|
+
body.initial_comment = options.initialComment;
|
|
819
|
+
}
|
|
820
|
+
if (options.threadTs) {
|
|
821
|
+
body.thread_ts = options.threadTs;
|
|
822
|
+
}
|
|
823
|
+
if (options.title) {
|
|
824
|
+
body.title = options.title;
|
|
825
|
+
}
|
|
826
|
+
if (binaryData) {
|
|
827
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
828
|
+
if (items[i].binary === undefined ||
|
|
829
|
+
items[i].binary[binaryPropertyName] === undefined) {
|
|
830
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
|
|
831
|
+
}
|
|
832
|
+
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
833
|
+
body.file = {
|
|
834
|
+
value: binaryDataBuffer,
|
|
835
|
+
options: {
|
|
836
|
+
filename: items[i].binary[binaryPropertyName].fileName,
|
|
837
|
+
contentType: items[i].binary[binaryPropertyName].mimeType,
|
|
838
|
+
},
|
|
839
|
+
};
|
|
840
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/files.upload', {}, qs, { 'Content-Type': 'multipart/form-data' }, { formData: body });
|
|
841
|
+
responseData = responseData.file;
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
const fileContent = this.getNodeParameter('fileContent', i);
|
|
845
|
+
body.content = fileContent;
|
|
846
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/files.upload', body, qs, { 'Content-Type': 'application/x-www-form-urlencoded' }, { form: body });
|
|
847
|
+
responseData = responseData.file;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (operation === 'getAll') {
|
|
851
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
852
|
+
const filters = this.getNodeParameter('filters', i);
|
|
853
|
+
if (filters.channelId) {
|
|
854
|
+
qs.channel = filters.channelId;
|
|
855
|
+
}
|
|
856
|
+
if (filters.showFilesHidden) {
|
|
857
|
+
qs.show_files_hidden_by_limit = filters.showFilesHidden;
|
|
858
|
+
}
|
|
859
|
+
if (filters.tsFrom) {
|
|
860
|
+
qs.ts_from = filters.tsFrom;
|
|
861
|
+
}
|
|
862
|
+
if (filters.tsTo) {
|
|
863
|
+
qs.ts_to = filters.tsTo;
|
|
864
|
+
}
|
|
865
|
+
if (filters.types) {
|
|
866
|
+
qs.types = filters.types.join(',');
|
|
867
|
+
}
|
|
868
|
+
if (filters.userId) {
|
|
869
|
+
qs.user = filters.userId;
|
|
870
|
+
}
|
|
871
|
+
if (returnAll) {
|
|
872
|
+
responseData = await GenericFunctions_1.slackApiRequestAllItems.call(this, 'files', 'GET', '/files.list', {}, qs);
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
qs.count = this.getNodeParameter('limit', i);
|
|
876
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/files.list', {}, qs);
|
|
877
|
+
responseData = responseData.files;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
if (operation === 'get') {
|
|
881
|
+
const fileId = this.getNodeParameter('fileId', i);
|
|
882
|
+
qs.file = fileId;
|
|
883
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/files.info', {}, qs);
|
|
884
|
+
responseData = responseData.file;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
if (resource === 'user') {
|
|
888
|
+
if (operation === 'info') {
|
|
889
|
+
qs.user = this.getNodeParameter('user', i);
|
|
890
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/users.info', {}, qs);
|
|
891
|
+
responseData = responseData.user;
|
|
892
|
+
}
|
|
893
|
+
if (operation === 'getAll') {
|
|
894
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
895
|
+
if (returnAll) {
|
|
896
|
+
responseData = await GenericFunctions_1.slackApiRequestAllItems.call(this, 'members', 'GET', '/users.list', {}, qs);
|
|
897
|
+
}
|
|
898
|
+
else {
|
|
899
|
+
qs.limit = this.getNodeParameter('limit', i);
|
|
900
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/users.list', {}, qs);
|
|
901
|
+
responseData = responseData.members;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
if (operation === 'getPresence') {
|
|
905
|
+
qs.user = this.getNodeParameter('user', i);
|
|
906
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/users.getPresence', {}, qs);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
if (resource === 'userGroup') {
|
|
910
|
+
if (operation === 'create') {
|
|
911
|
+
const name = this.getNodeParameter('name', i);
|
|
912
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
913
|
+
const body = {
|
|
914
|
+
name,
|
|
915
|
+
};
|
|
916
|
+
Object.assign(body, additionalFields);
|
|
917
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/usergroups.create', body, qs);
|
|
918
|
+
responseData = responseData.usergroup;
|
|
919
|
+
}
|
|
920
|
+
if (operation === 'enable') {
|
|
921
|
+
const userGroupId = this.getNodeParameter('userGroupId', i);
|
|
922
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
923
|
+
const body = {
|
|
924
|
+
usergroup: userGroupId,
|
|
925
|
+
};
|
|
926
|
+
Object.assign(body, additionalFields);
|
|
927
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/usergroups.enable', body, qs);
|
|
928
|
+
responseData = responseData.usergroup;
|
|
929
|
+
}
|
|
930
|
+
if (operation === 'disable') {
|
|
931
|
+
const userGroupId = this.getNodeParameter('userGroupId', i);
|
|
932
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
933
|
+
const body = {
|
|
934
|
+
usergroup: userGroupId,
|
|
935
|
+
};
|
|
936
|
+
Object.assign(body, additionalFields);
|
|
937
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/usergroups.disable', body, qs);
|
|
938
|
+
responseData = responseData.usergroup;
|
|
939
|
+
}
|
|
940
|
+
if (operation === 'getAll') {
|
|
941
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
942
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
943
|
+
const qs = {};
|
|
944
|
+
Object.assign(qs, additionalFields);
|
|
945
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'GET', '/usergroups.list', {}, qs);
|
|
946
|
+
responseData = responseData.usergroups;
|
|
947
|
+
if (!returnAll) {
|
|
948
|
+
const limit = this.getNodeParameter('limit', i);
|
|
949
|
+
responseData = responseData.slice(0, limit);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
if (operation === 'update') {
|
|
953
|
+
const userGroupId = this.getNodeParameter('userGroupId', i);
|
|
954
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
955
|
+
const body = {
|
|
956
|
+
usergroup: userGroupId,
|
|
957
|
+
};
|
|
958
|
+
Object.assign(body, updateFields);
|
|
959
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/usergroups.update', body, qs);
|
|
960
|
+
responseData = responseData.usergroup;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
if (resource === 'userProfile') {
|
|
964
|
+
if (operation === 'update') {
|
|
965
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
966
|
+
const timezone = this.getTimezone();
|
|
967
|
+
const body = {};
|
|
968
|
+
Object.assign(body, additionalFields);
|
|
969
|
+
if (body.status_expiration === undefined) {
|
|
970
|
+
body.status_expiration = 0;
|
|
971
|
+
}
|
|
972
|
+
else {
|
|
973
|
+
body.status_expiration = moment_1.default.tz(body.status_expiration, timezone).unix();
|
|
974
|
+
}
|
|
975
|
+
if (body.customFieldUi) {
|
|
976
|
+
const customFields = body.customFieldUi
|
|
977
|
+
.customFieldValues;
|
|
978
|
+
body.fields = {};
|
|
979
|
+
for (const customField of customFields) {
|
|
980
|
+
body.fields[customField.id] = {
|
|
981
|
+
value: customField.value,
|
|
982
|
+
alt: customField.alt,
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/users.profile.set', { profile: body }, qs);
|
|
987
|
+
responseData = responseData.profile;
|
|
988
|
+
}
|
|
989
|
+
if (operation === 'get') {
|
|
990
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
991
|
+
const qs = {};
|
|
992
|
+
Object.assign(qs, additionalFields);
|
|
993
|
+
responseData = await GenericFunctions_1.slackApiRequest.call(this, 'POST', '/users.profile.get', undefined, qs);
|
|
994
|
+
responseData = responseData.profile;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
|
|
998
|
+
returnData.push(...executionData);
|
|
999
|
+
}
|
|
1000
|
+
catch (error) {
|
|
1001
|
+
if (this.continueOnFail()) {
|
|
1002
|
+
returnData.push({ json: { error: error.message } });
|
|
1003
|
+
continue;
|
|
1004
|
+
}
|
|
1005
|
+
throw error;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
return this.prepareOutputData(returnData);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
exports.SlackV1 = SlackV1;
|
|
1012
|
+
//# sourceMappingURL=SlackV1.node.js.map
|