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