@pipedream/slack 0.9.0 → 0.9.2
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/actions/add-emoji-reaction/add-emoji-reaction.mjs +2 -2
- package/actions/approve-workflow/approve-workflow.mjs +6 -4
- package/actions/archive-channel/archive-channel.mjs +2 -2
- package/actions/common/send-message.mjs +6 -4
- package/actions/create-channel/create-channel.mjs +2 -2
- package/actions/create-reminder/create-reminder.mjs +2 -2
- package/actions/delete-file/delete-file.mjs +11 -2
- package/actions/delete-message/delete-message.mjs +2 -2
- package/actions/find-message/find-message.mjs +1 -1
- package/actions/find-user-by-email/find-user-by-email.mjs +2 -2
- package/actions/get-file/get-file.mjs +11 -2
- package/actions/invite-user-to-channel/invite-user-to-channel.mjs +15 -7
- package/actions/kick-user/kick-user.mjs +15 -7
- package/actions/list-channels/list-channels.mjs +32 -4
- package/actions/list-files/list-files.mjs +16 -3
- package/actions/list-group-members/list-group-members.mjs +33 -12
- package/actions/list-members-in-channel/list-members-in-channel.mjs +30 -5
- package/actions/list-replies/list-replies.mjs +32 -5
- package/actions/list-users/list-users.mjs +32 -5
- package/actions/reply-to-a-message/reply-to-a-message.mjs +1 -1
- package/actions/send-block-kit-message/send-block-kit-message.mjs +1 -1
- package/actions/send-large-message/send-large-message.mjs +8 -5
- package/actions/send-message/send-message.mjs +1 -1
- package/actions/send-message-advanced/send-message-advanced.mjs +1 -1
- package/actions/send-message-to-channel/send-message-to-channel.mjs +1 -1
- package/actions/send-message-to-user-or-group/send-message-to-user-or-group.mjs +1 -1
- package/actions/set-channel-description/set-channel-description.mjs +2 -2
- package/actions/set-channel-topic/set-channel-topic.mjs +2 -2
- package/actions/set-status/set-status.mjs +2 -2
- package/actions/update-group-members/update-group-members.mjs +3 -3
- package/actions/update-message/update-message.mjs +2 -2
- package/actions/update-profile/update-profile.mjs +2 -2
- package/actions/upload-file/upload-file.mjs +51 -7
- package/actions/verify-slack-signature/verify-slack-signature.mjs +1 -1
- package/common/constants.mjs +1 -1
- package/package.json +2 -2
- package/slack.app.mjs +267 -56
- package/sources/common/base.mjs +6 -6
- package/sources/new-channel-created/new-channel-created.mjs +1 -1
- package/sources/new-direct-message/new-direct-message.mjs +1 -1
- package/sources/new-interaction-event-received/new-interaction-event-received.mjs +1 -1
- package/sources/new-keyword-mention/new-keyword-mention.mjs +1 -1
- package/sources/new-message-in-channels/new-message-in-channels.mjs +1 -1
- package/sources/new-reaction-added/new-reaction-added.mjs +1 -1
- package/sources/new-saved-message/new-saved-message.mjs +1 -1
- package/sources/new-user-added/new-user-added.mjs +1 -1
- package/sources/new-user-mention/new-user-mention.mjs +1 -1
package/slack.app.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { WebClient } from "@slack/web-api";
|
|
2
2
|
import constants from "./common/constants.mjs";
|
|
3
|
+
import get from "lodash/get.js";
|
|
4
|
+
import retry from "async-retry";
|
|
3
5
|
|
|
4
6
|
export default {
|
|
5
7
|
type: "app",
|
|
@@ -15,27 +17,24 @@ export default {
|
|
|
15
17
|
const types = [
|
|
16
18
|
"im",
|
|
17
19
|
];
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
conversationsResp,
|
|
21
|
-
] = await Promise.all([
|
|
22
|
-
prevContext.userNames ?? this.userNames(),
|
|
23
|
-
this.availableConversations(types.join(), prevContext.cursor),
|
|
24
|
-
]);
|
|
20
|
+
let conversationsResp
|
|
21
|
+
= await this.availableConversations(types.join(), prevContext.cursor, true);
|
|
25
22
|
if (channelId) {
|
|
26
|
-
const { members } = await this.
|
|
23
|
+
const { members } = await this.listChannelMembers({
|
|
27
24
|
channel: channelId,
|
|
25
|
+
throwRateLimitError: true,
|
|
28
26
|
});
|
|
29
27
|
conversationsResp.conversations = conversationsResp.conversations
|
|
30
28
|
.filter((c) => members.includes(c.user || c.id));
|
|
31
29
|
}
|
|
30
|
+
const userIds = conversationsResp.conversations.map(({ user }) => user);
|
|
31
|
+
const userNames = await this.userNameLookup(userIds);
|
|
32
32
|
return {
|
|
33
33
|
options: conversationsResp.conversations.map((c) => ({
|
|
34
34
|
label: `@${userNames[c.user]}`,
|
|
35
35
|
value: c.user || c.id,
|
|
36
36
|
})),
|
|
37
37
|
context: {
|
|
38
|
-
userNames,
|
|
39
38
|
cursor: conversationsResp.cursor,
|
|
40
39
|
},
|
|
41
40
|
};
|
|
@@ -50,7 +49,7 @@ export default {
|
|
|
50
49
|
const types = [
|
|
51
50
|
"mpim",
|
|
52
51
|
];
|
|
53
|
-
const resp = await this.availableConversations(types.join(), cursor);
|
|
52
|
+
const resp = await this.availableConversations(types.join(), cursor, true);
|
|
54
53
|
return {
|
|
55
54
|
options: resp.conversations.map((c) => {
|
|
56
55
|
return {
|
|
@@ -69,7 +68,9 @@ export default {
|
|
|
69
68
|
label: "User Group",
|
|
70
69
|
description: "The encoded ID of the User Group.",
|
|
71
70
|
async options() {
|
|
72
|
-
const { usergroups } = await this.usergroupsList(
|
|
71
|
+
const { usergroups } = await this.usergroupsList({
|
|
72
|
+
throwRateLimitError: true,
|
|
73
|
+
});
|
|
73
74
|
return usergroups.map((c) => ({
|
|
74
75
|
label: c.name,
|
|
75
76
|
value: c.id,
|
|
@@ -81,7 +82,9 @@ export default {
|
|
|
81
82
|
label: "Reminder",
|
|
82
83
|
description: "Select a reminder",
|
|
83
84
|
async options() {
|
|
84
|
-
const { reminders } = await this.remindersList(
|
|
85
|
+
const { reminders } = await this.remindersList({
|
|
86
|
+
throwRateLimitError: true,
|
|
87
|
+
});
|
|
85
88
|
return reminders.map((c) => ({
|
|
86
89
|
label: c.text,
|
|
87
90
|
value: c.id,
|
|
@@ -95,15 +98,14 @@ export default {
|
|
|
95
98
|
async options({
|
|
96
99
|
prevContext, types,
|
|
97
100
|
}) {
|
|
98
|
-
let {
|
|
99
|
-
cursor,
|
|
100
|
-
userNames: userNamesOrPromise,
|
|
101
|
-
} = prevContext;
|
|
101
|
+
let { cursor } = prevContext;
|
|
102
102
|
if (prevContext?.types) {
|
|
103
103
|
types = prevContext.types;
|
|
104
104
|
}
|
|
105
105
|
if (types == null) {
|
|
106
|
-
const { response_metadata: { scopes } } = await this.authTest(
|
|
106
|
+
const { response_metadata: { scopes } } = await this.authTest({
|
|
107
|
+
throwRateLimitError: true,
|
|
108
|
+
});
|
|
107
109
|
types = [
|
|
108
110
|
"public_channel",
|
|
109
111
|
];
|
|
@@ -115,19 +117,17 @@ export default {
|
|
|
115
117
|
}
|
|
116
118
|
if (scopes.includes("im:read")) {
|
|
117
119
|
types.push("im");
|
|
118
|
-
userNamesOrPromise = this.userNames();
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
: conversationsResp.conversations.filter((c) => !c.is_im);
|
|
122
|
+
const conversationsResp = await this.availableConversations(types.join(), cursor, true);
|
|
123
|
+
let conversations, userNames;
|
|
124
|
+
if (types.includes("im")) {
|
|
125
|
+
conversations = conversationsResp.conversations;
|
|
126
|
+
const userIds = conversations.map(({ user }) => user);
|
|
127
|
+
userNames = await this.userNameLookup(userIds);
|
|
128
|
+
} else {
|
|
129
|
+
conversations = conversationsResp.conversations.filter((c) => !c.is_im);
|
|
130
|
+
}
|
|
131
131
|
return {
|
|
132
132
|
options: conversations.map((c) => {
|
|
133
133
|
if (c.is_im) {
|
|
@@ -152,7 +152,6 @@ export default {
|
|
|
152
152
|
context: {
|
|
153
153
|
types,
|
|
154
154
|
cursor: conversationsResp.cursor,
|
|
155
|
-
userNames,
|
|
156
155
|
},
|
|
157
156
|
};
|
|
158
157
|
},
|
|
@@ -167,7 +166,6 @@ export default {
|
|
|
167
166
|
channelsFilter = (channel) => channel,
|
|
168
167
|
excludeArchived = true,
|
|
169
168
|
}) {
|
|
170
|
-
const userNames = prevContext.userNames || await this.userNames();
|
|
171
169
|
const {
|
|
172
170
|
channels,
|
|
173
171
|
response_metadata: { next_cursor: cursor },
|
|
@@ -176,8 +174,15 @@ export default {
|
|
|
176
174
|
cursor: prevContext.cursor,
|
|
177
175
|
limit: constants.LIMIT,
|
|
178
176
|
exclude_archived: excludeArchived,
|
|
177
|
+
throwRateLimitError: true,
|
|
179
178
|
});
|
|
180
179
|
|
|
180
|
+
let userNames;
|
|
181
|
+
if (types.includes("im")) {
|
|
182
|
+
const userIds = channels.filter(({ is_im }) => is_im).map(({ user }) => user);
|
|
183
|
+
userNames = await this.userNameLookup(userIds);
|
|
184
|
+
}
|
|
185
|
+
|
|
181
186
|
const options = channels
|
|
182
187
|
.filter(channelsFilter)
|
|
183
188
|
.map((c) => {
|
|
@@ -205,7 +210,6 @@ export default {
|
|
|
205
210
|
options,
|
|
206
211
|
context: {
|
|
207
212
|
cursor,
|
|
208
|
-
userNames,
|
|
209
213
|
},
|
|
210
214
|
};
|
|
211
215
|
},
|
|
@@ -220,6 +224,8 @@ export default {
|
|
|
220
224
|
response_metadata: { next_cursor: cursor },
|
|
221
225
|
} = await this.authTeamsList({
|
|
222
226
|
cursor: prevContext.cursor,
|
|
227
|
+
limit: constants.LIMIT,
|
|
228
|
+
throwRateLimitError: true,
|
|
223
229
|
});
|
|
224
230
|
|
|
225
231
|
return {
|
|
@@ -266,9 +272,11 @@ export default {
|
|
|
266
272
|
async options({
|
|
267
273
|
channel, page,
|
|
268
274
|
}) {
|
|
269
|
-
const { files } = await this.
|
|
275
|
+
const { files } = await this.listFiles({
|
|
270
276
|
channel,
|
|
271
277
|
page: page + 1,
|
|
278
|
+
count: constants.LIMIT,
|
|
279
|
+
throwRateLimitError: true,
|
|
272
280
|
});
|
|
273
281
|
return files?.map(({
|
|
274
282
|
id: value, name: label,
|
|
@@ -342,7 +350,9 @@ export default {
|
|
|
342
350
|
description: "Optionally provide an emoji to use as the icon for this message. E.g., `:fire:` Overrides `icon_url`. Must be used in conjunction with `Send as User` set to `false`, otherwise ignored.",
|
|
343
351
|
optional: true,
|
|
344
352
|
async options() {
|
|
345
|
-
return await this.getCustomEmojis(
|
|
353
|
+
return await this.getCustomEmojis({
|
|
354
|
+
throwRateLimitError: true,
|
|
355
|
+
});
|
|
346
356
|
},
|
|
347
357
|
},
|
|
348
358
|
content: {
|
|
@@ -423,6 +433,20 @@ export default {
|
|
|
423
433
|
default: false,
|
|
424
434
|
optional: true,
|
|
425
435
|
},
|
|
436
|
+
pageSize: {
|
|
437
|
+
type: "integer",
|
|
438
|
+
label: "Page Size",
|
|
439
|
+
description: "The number of results to include in a page. Default: 250",
|
|
440
|
+
default: constants.LIMIT,
|
|
441
|
+
optional: true,
|
|
442
|
+
},
|
|
443
|
+
numPages: {
|
|
444
|
+
type: "integer",
|
|
445
|
+
label: "Number of Pages",
|
|
446
|
+
description: "The number of pages to retrieve. Default: 1",
|
|
447
|
+
default: 1,
|
|
448
|
+
optional: true,
|
|
449
|
+
},
|
|
426
450
|
},
|
|
427
451
|
methods: {
|
|
428
452
|
getChannelLabel(resource) {
|
|
@@ -448,22 +472,18 @@ export default {
|
|
|
448
472
|
* token
|
|
449
473
|
*/
|
|
450
474
|
sdk() {
|
|
451
|
-
return new WebClient(this.getToken()
|
|
475
|
+
return new WebClient(this.getToken(), {
|
|
476
|
+
rejectRateLimitedCalls: true,
|
|
477
|
+
});
|
|
452
478
|
},
|
|
453
479
|
async makeRequest({
|
|
454
|
-
method = "", ...args
|
|
480
|
+
method = "", throwRateLimitError = false, ...args
|
|
455
481
|
} = {}) {
|
|
456
|
-
let response;
|
|
457
482
|
const props = method.split(".");
|
|
458
483
|
const sdk = props.reduce((reduction, prop) =>
|
|
459
484
|
reduction[prop], this.sdk());
|
|
460
485
|
|
|
461
|
-
|
|
462
|
-
response = await sdk(args);
|
|
463
|
-
} catch (error) {
|
|
464
|
-
console.log(`Error calling ${method}`, error);
|
|
465
|
-
throw error;
|
|
466
|
-
}
|
|
486
|
+
const response = await this._withRetries(() => sdk(args), throwRateLimitError);
|
|
467
487
|
|
|
468
488
|
if (!response.ok) {
|
|
469
489
|
console.log(`Error in response with method ${method}`, response.error);
|
|
@@ -471,6 +491,28 @@ export default {
|
|
|
471
491
|
}
|
|
472
492
|
return response;
|
|
473
493
|
},
|
|
494
|
+
async _withRetries(apiCall, throwRateLimitError = false) {
|
|
495
|
+
const retryOpts = {
|
|
496
|
+
retries: 3,
|
|
497
|
+
minTimeout: 30000,
|
|
498
|
+
};
|
|
499
|
+
return retry(async (bail) => {
|
|
500
|
+
try {
|
|
501
|
+
return await apiCall();
|
|
502
|
+
} catch (error) {
|
|
503
|
+
const statusCode = get(error, "code");
|
|
504
|
+
if (statusCode === "slack_webapi_rate_limited_error") {
|
|
505
|
+
if (throwRateLimitError) {
|
|
506
|
+
bail(`Rate limit exceeded. ${error}`);
|
|
507
|
+
} else {
|
|
508
|
+
console.log(`Rate limit exceeded. Will retry in ${retryOpts.minTimeout / 1000} seconds`);
|
|
509
|
+
throw error;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
bail(`${error}`);
|
|
513
|
+
}
|
|
514
|
+
}, retryOpts);
|
|
515
|
+
},
|
|
474
516
|
/**
|
|
475
517
|
* Returns a list of channel-like conversations in a workspace. The
|
|
476
518
|
* "channels" returned depend on what the calling token has access to and
|
|
@@ -483,7 +525,7 @@ export default {
|
|
|
483
525
|
* @returns an object containing a list of conversations and the cursor for the next
|
|
484
526
|
* page of conversations
|
|
485
527
|
*/
|
|
486
|
-
async availableConversations(types, cursor) {
|
|
528
|
+
async availableConversations(types, cursor, throwRateLimitError = false) {
|
|
487
529
|
const {
|
|
488
530
|
channels: conversations,
|
|
489
531
|
response_metadata: { next_cursor: nextCursor },
|
|
@@ -492,18 +534,14 @@ export default {
|
|
|
492
534
|
cursor,
|
|
493
535
|
limit: constants.LIMIT,
|
|
494
536
|
exclude_archived: true,
|
|
537
|
+
throwRateLimitError,
|
|
495
538
|
});
|
|
496
539
|
return {
|
|
497
540
|
cursor: nextCursor,
|
|
498
541
|
conversations,
|
|
499
542
|
};
|
|
500
543
|
},
|
|
501
|
-
|
|
502
|
-
* Returns a mapping from user ID to user name for all users in the workspace
|
|
503
|
-
*
|
|
504
|
-
* @returns the mapping from user ID to user name
|
|
505
|
-
*/
|
|
506
|
-
async userNames() {
|
|
544
|
+
async userNameLookup(ids = [], throwRateLimitError = true, args = {}) {
|
|
507
545
|
let cursor;
|
|
508
546
|
const userNames = {};
|
|
509
547
|
do {
|
|
@@ -511,15 +549,20 @@ export default {
|
|
|
511
549
|
members: users,
|
|
512
550
|
response_metadata: { next_cursor: nextCursor },
|
|
513
551
|
} = await this.usersList({
|
|
552
|
+
limit: constants.LIMIT,
|
|
514
553
|
cursor,
|
|
554
|
+
throwRateLimitError,
|
|
555
|
+
...args,
|
|
515
556
|
});
|
|
516
557
|
|
|
517
558
|
for (const user of users) {
|
|
518
|
-
|
|
559
|
+
if (ids.includes(user.id)) {
|
|
560
|
+
userNames[user.id] = user.name;
|
|
561
|
+
}
|
|
519
562
|
}
|
|
520
563
|
|
|
521
564
|
cursor = nextCursor;
|
|
522
|
-
} while (cursor);
|
|
565
|
+
} while (cursor && Object.keys(userNames).length < ids.length);
|
|
523
566
|
return userNames;
|
|
524
567
|
},
|
|
525
568
|
/**
|
|
@@ -558,6 +601,7 @@ export default {
|
|
|
558
601
|
});
|
|
559
602
|
},
|
|
560
603
|
authTeamsList(args = {}) {
|
|
604
|
+
args.limit ||= constants.LIMIT;
|
|
561
605
|
return this.makeRequest({
|
|
562
606
|
method: "auth.teams.list",
|
|
563
607
|
...args,
|
|
@@ -570,7 +614,7 @@ export default {
|
|
|
570
614
|
* @param {string} [args.cursor] Pagination value e.g. (`dXNlcjpVMDYxTkZUVDI=`)
|
|
571
615
|
* @param {boolean} [args.exclude_archived] Set to `true` to exclude archived channels
|
|
572
616
|
* from the list. Defaults to `false`
|
|
573
|
-
* @param {number} [args.limit] Pagination value. Defaults to `
|
|
617
|
+
* @param {number} [args.limit] Pagination value. Defaults to `250`
|
|
574
618
|
* @param {string} [args.team_id] Encoded team id to list users in,
|
|
575
619
|
* required if org token is used
|
|
576
620
|
* @param {string} [args.types] Mix and match channel types by providing a
|
|
@@ -582,6 +626,7 @@ export default {
|
|
|
582
626
|
* @returns Promise
|
|
583
627
|
*/
|
|
584
628
|
usersConversations(args = {}) {
|
|
629
|
+
args.limit ||= constants.LIMIT;
|
|
585
630
|
return this.makeRequest({
|
|
586
631
|
method: "users.conversations",
|
|
587
632
|
user: this.$auth.oauth_uid,
|
|
@@ -595,12 +640,13 @@ export default {
|
|
|
595
640
|
* @param {string} [args.cursor] Pagination value e.g. (`dXNlcjpVMDYxTkZUVDI=`)
|
|
596
641
|
* @param {boolean} [args.include_locale] Set this to `true` to receive the locale
|
|
597
642
|
* for users. Defaults to `false`
|
|
598
|
-
* @param {number} [args.limit]
|
|
643
|
+
* @param {number} [args.limit] The maximum number of items to return. Defaults to `250`
|
|
599
644
|
* @param {string} [args.team_id] Encoded team id to list users in,
|
|
600
645
|
* required if org token is used
|
|
601
646
|
* @returns Promise
|
|
602
647
|
*/
|
|
603
648
|
usersList(args = {}) {
|
|
649
|
+
args.limit ||= constants.LIMIT;
|
|
604
650
|
return this.makeRequest({
|
|
605
651
|
method: "users.list",
|
|
606
652
|
...args,
|
|
@@ -613,7 +659,7 @@ export default {
|
|
|
613
659
|
* @param {string} [args.cursor] Pagination value e.g. (`dXNlcjpVMDYxTkZUVDI=`)
|
|
614
660
|
* @param {boolean} [args.exclude_archived] Set to `true` to exclude archived channels
|
|
615
661
|
* from the list. Defaults to `false`
|
|
616
|
-
* @param {number} [args.limit] pagination value. Defaults to `
|
|
662
|
+
* @param {number} [args.limit] pagination value. Defaults to `250`
|
|
617
663
|
* @param {string} [args.team_id] encoded team id to list users in,
|
|
618
664
|
* required if org token is used
|
|
619
665
|
* @param {string} [args.types] Mix and match channel types by providing a
|
|
@@ -622,6 +668,7 @@ export default {
|
|
|
622
668
|
* @returns Promise
|
|
623
669
|
*/
|
|
624
670
|
conversationsList(args = {}) {
|
|
671
|
+
args.limit ||= constants.LIMIT;
|
|
625
672
|
return this.makeRequest({
|
|
626
673
|
method: "conversations.list",
|
|
627
674
|
...args,
|
|
@@ -641,6 +688,7 @@ export default {
|
|
|
641
688
|
* @returns Promise
|
|
642
689
|
*/
|
|
643
690
|
conversationsHistory(args = {}) {
|
|
691
|
+
args.limit ||= constants.LIMIT;
|
|
644
692
|
return this.makeRequest({
|
|
645
693
|
method: "conversations.history",
|
|
646
694
|
...args,
|
|
@@ -683,7 +731,7 @@ export default {
|
|
|
683
731
|
* User Scopes: `search:read`
|
|
684
732
|
* @param {SearchMessagesArguments} args Arguments object
|
|
685
733
|
* @param {string} args.query Search query
|
|
686
|
-
* @param {number} [args.count] Number of items to return per page. Default `
|
|
734
|
+
* @param {number} [args.count] Number of items to return per page. Default `250`
|
|
687
735
|
* @param {string} [args.cursor] Use this when getting results with cursormark
|
|
688
736
|
* pagination. For first call send `*` for subsequent calls, send the value of
|
|
689
737
|
* `next_cursor` returned in the previous call's results
|
|
@@ -696,6 +744,7 @@ export default {
|
|
|
696
744
|
* @returns Promise
|
|
697
745
|
*/
|
|
698
746
|
searchMessages(args = {}) {
|
|
747
|
+
args.count ||= constants.LIMIT;
|
|
699
748
|
return this.makeRequest({
|
|
700
749
|
method: "search.messages",
|
|
701
750
|
...args,
|
|
@@ -722,14 +771,17 @@ export default {
|
|
|
722
771
|
* @returns Promise
|
|
723
772
|
*/
|
|
724
773
|
reactionsList(args = {}) {
|
|
774
|
+
args.limit ||= constants.LIMIT;
|
|
725
775
|
return this.makeRequest({
|
|
726
776
|
method: "reactions.list",
|
|
727
777
|
...args,
|
|
728
778
|
});
|
|
729
779
|
},
|
|
730
|
-
async getCustomEmojis() {
|
|
780
|
+
async getCustomEmojis(args = {}) {
|
|
731
781
|
const resp = await this.sdk().emoji.list({
|
|
732
782
|
include_categories: true,
|
|
783
|
+
limit: constants.LIMIT,
|
|
784
|
+
...args,
|
|
733
785
|
});
|
|
734
786
|
|
|
735
787
|
const emojis = Object.keys(resp.emoji);
|
|
@@ -738,5 +790,164 @@ export default {
|
|
|
738
790
|
}
|
|
739
791
|
return emojis;
|
|
740
792
|
},
|
|
793
|
+
listChannelMembers(args = {}) {
|
|
794
|
+
args.limit ||= constants.LIMIT;
|
|
795
|
+
return this.makeRequest({
|
|
796
|
+
method: "conversations.members",
|
|
797
|
+
...args,
|
|
798
|
+
});
|
|
799
|
+
},
|
|
800
|
+
listFiles(args = {}) {
|
|
801
|
+
args.count ||= constants.LIMIT;
|
|
802
|
+
return this.makeRequest({
|
|
803
|
+
method: "files.list",
|
|
804
|
+
...args,
|
|
805
|
+
});
|
|
806
|
+
},
|
|
807
|
+
listGroupMembers(args = {}) {
|
|
808
|
+
args.limit ||= constants.LIMIT;
|
|
809
|
+
return this.makeRequest({
|
|
810
|
+
method: "usergroups.users.list",
|
|
811
|
+
...args,
|
|
812
|
+
});
|
|
813
|
+
},
|
|
814
|
+
getFileInfo(args = {}) {
|
|
815
|
+
return this.makeRequest({
|
|
816
|
+
method: "files.info",
|
|
817
|
+
...args,
|
|
818
|
+
});
|
|
819
|
+
},
|
|
820
|
+
getUserProfile(args = {}) {
|
|
821
|
+
return this.makeRequest({
|
|
822
|
+
method: "users.profile.get",
|
|
823
|
+
...args,
|
|
824
|
+
});
|
|
825
|
+
},
|
|
826
|
+
getBotInfo(args = {}) {
|
|
827
|
+
return this.makeRequest({
|
|
828
|
+
method: "bots.info",
|
|
829
|
+
...args,
|
|
830
|
+
});
|
|
831
|
+
},
|
|
832
|
+
getTeamInfo(args = {}) {
|
|
833
|
+
return this.makeRequest({
|
|
834
|
+
method: "team.info",
|
|
835
|
+
...args,
|
|
836
|
+
});
|
|
837
|
+
},
|
|
838
|
+
getConversationReplies(args = {}) {
|
|
839
|
+
return this.makeRequest({
|
|
840
|
+
method: "conversations.replies",
|
|
841
|
+
...args,
|
|
842
|
+
});
|
|
843
|
+
},
|
|
844
|
+
addReactions(args = {}) {
|
|
845
|
+
return this.makeRequest({
|
|
846
|
+
method: "reactions.add",
|
|
847
|
+
...args,
|
|
848
|
+
});
|
|
849
|
+
},
|
|
850
|
+
postChatMessage(args = {}) {
|
|
851
|
+
return this.makeRequest({
|
|
852
|
+
method: "chat.postMessage",
|
|
853
|
+
...args,
|
|
854
|
+
});
|
|
855
|
+
},
|
|
856
|
+
archiveConversations(args = {}) {
|
|
857
|
+
return this.makeRequest({
|
|
858
|
+
method: "conversations.archive",
|
|
859
|
+
...args,
|
|
860
|
+
});
|
|
861
|
+
},
|
|
862
|
+
scheduleMessage(args = {}) {
|
|
863
|
+
return this.makeRequest({
|
|
864
|
+
method: "chat.scheduleMessage",
|
|
865
|
+
...args,
|
|
866
|
+
});
|
|
867
|
+
},
|
|
868
|
+
createConversations(args = {}) {
|
|
869
|
+
return this.makeRequest({
|
|
870
|
+
method: "conversations.create",
|
|
871
|
+
...args,
|
|
872
|
+
});
|
|
873
|
+
},
|
|
874
|
+
inviteToConversation(args = {}) {
|
|
875
|
+
return this.makeRequest({
|
|
876
|
+
method: "conversations.invite",
|
|
877
|
+
...args,
|
|
878
|
+
});
|
|
879
|
+
},
|
|
880
|
+
kickUserFromConversation(args = {}) {
|
|
881
|
+
return this.makeRequest({
|
|
882
|
+
method: "conversations.kick",
|
|
883
|
+
...args,
|
|
884
|
+
});
|
|
885
|
+
},
|
|
886
|
+
addReminders(args = {}) {
|
|
887
|
+
return this.makeRequest({
|
|
888
|
+
method: "reminders.add",
|
|
889
|
+
...args,
|
|
890
|
+
});
|
|
891
|
+
},
|
|
892
|
+
deleteFiles(args = {}) {
|
|
893
|
+
return this.makeRequest({
|
|
894
|
+
method: "files.delete",
|
|
895
|
+
...args,
|
|
896
|
+
});
|
|
897
|
+
},
|
|
898
|
+
deleteMessage(args = {}) {
|
|
899
|
+
return this.makeRequest({
|
|
900
|
+
method: "chat.delete",
|
|
901
|
+
...args,
|
|
902
|
+
});
|
|
903
|
+
},
|
|
904
|
+
lookupUserByEmail(args = {}) {
|
|
905
|
+
return this.makeRequest({
|
|
906
|
+
method: "users.lookupByEmail",
|
|
907
|
+
...args,
|
|
908
|
+
});
|
|
909
|
+
},
|
|
910
|
+
setChannelDescription(args = {}) {
|
|
911
|
+
return this.makeRequest({
|
|
912
|
+
method: "conversations.setPurpose",
|
|
913
|
+
...args,
|
|
914
|
+
});
|
|
915
|
+
},
|
|
916
|
+
setChannelTopic(args = {}) {
|
|
917
|
+
return this.makeRequest({
|
|
918
|
+
method: "conversations.setTopic",
|
|
919
|
+
...args,
|
|
920
|
+
});
|
|
921
|
+
},
|
|
922
|
+
updateProfile(args = {}) {
|
|
923
|
+
return this.makeRequest({
|
|
924
|
+
method: "users.profile.set",
|
|
925
|
+
...args,
|
|
926
|
+
});
|
|
927
|
+
},
|
|
928
|
+
updateGroupMembers(args = {}) {
|
|
929
|
+
return this.makeRequest({
|
|
930
|
+
method: "usergroups.users.update",
|
|
931
|
+
...args,
|
|
932
|
+
});
|
|
933
|
+
},
|
|
934
|
+
updateMessage(args = {}) {
|
|
935
|
+
return this.makeRequest({
|
|
936
|
+
method: "chat.update",
|
|
937
|
+
...args,
|
|
938
|
+
});
|
|
939
|
+
},
|
|
940
|
+
getUploadUrl(args = {}) {
|
|
941
|
+
return this.makeRequest({
|
|
942
|
+
method: "files.getUploadURLExternal",
|
|
943
|
+
...args,
|
|
944
|
+
});
|
|
945
|
+
},
|
|
946
|
+
completeUpload(args = {}) {
|
|
947
|
+
return this.makeRequest({
|
|
948
|
+
method: "files.completeUploadExternal",
|
|
949
|
+
...args,
|
|
950
|
+
});
|
|
951
|
+
},
|
|
741
952
|
},
|
|
742
953
|
};
|
package/sources/common/base.mjs
CHANGED
|
@@ -85,7 +85,7 @@ export default {
|
|
|
85
85
|
},
|
|
86
86
|
async getUserName(id) {
|
|
87
87
|
return this.maybeCached(`users:${id}`, async () => {
|
|
88
|
-
const info = await this.slack.
|
|
88
|
+
const info = await this.slack.usersInfo({
|
|
89
89
|
user: id,
|
|
90
90
|
});
|
|
91
91
|
if (!info.ok) throw new Error(info.error);
|
|
@@ -94,7 +94,7 @@ export default {
|
|
|
94
94
|
},
|
|
95
95
|
async getRealName(id) {
|
|
96
96
|
return this.maybeCached(`users_real_names:${id}`, async () => {
|
|
97
|
-
const info = await this.slack.
|
|
97
|
+
const info = await this.slack.usersInfo({
|
|
98
98
|
user: id,
|
|
99
99
|
});
|
|
100
100
|
if (!info.ok) throw new Error(info.error);
|
|
@@ -103,7 +103,7 @@ export default {
|
|
|
103
103
|
},
|
|
104
104
|
async getBotName(id) {
|
|
105
105
|
return this.maybeCached(`bots:${id}`, async () => {
|
|
106
|
-
const info = await this.slack.
|
|
106
|
+
const info = await this.slack.getBotInfo({
|
|
107
107
|
bot: id,
|
|
108
108
|
});
|
|
109
109
|
if (!info.ok) throw new Error(info.error);
|
|
@@ -112,7 +112,7 @@ export default {
|
|
|
112
112
|
},
|
|
113
113
|
async getConversationName(id) {
|
|
114
114
|
return this.maybeCached(`conversations:${id}`, async () => {
|
|
115
|
-
const info = await this.slack.
|
|
115
|
+
const info = await this.slack.conversationsInfo({
|
|
116
116
|
channel: id,
|
|
117
117
|
});
|
|
118
118
|
if (!info.ok) throw new Error(info.error);
|
|
@@ -125,7 +125,7 @@ export default {
|
|
|
125
125
|
async getTeamName(id) {
|
|
126
126
|
return this.maybeCached(`team:${id}`, async () => {
|
|
127
127
|
try {
|
|
128
|
-
const info = await this.slack.
|
|
128
|
+
const info = await this.slack.getTeamInfo({
|
|
129
129
|
team: id,
|
|
130
130
|
});
|
|
131
131
|
return info.team.name;
|
|
@@ -144,7 +144,7 @@ export default {
|
|
|
144
144
|
return await this.maybeCached(
|
|
145
145
|
`lastMessage:${channel}:${ts}`,
|
|
146
146
|
async () => {
|
|
147
|
-
const response = await this.slack.sdk().
|
|
147
|
+
const response = await this.slack.sdk().getConversationReplies({
|
|
148
148
|
channel,
|
|
149
149
|
ts,
|
|
150
150
|
limit: 1,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
...common,
|
|
6
6
|
key: "slack-new-direct-message",
|
|
7
7
|
name: "New Direct Message (Instant)",
|
|
8
|
-
version: "1.0.
|
|
8
|
+
version: "1.0.22",
|
|
9
9
|
description: "Emit new event when a message was posted in a direct message channel",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
@@ -3,7 +3,7 @@ import sampleEmit from "./test-event.mjs";
|
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
name: "New Interaction Events (Instant)",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.19",
|
|
7
7
|
key: "slack-new-interaction-event-received",
|
|
8
8
|
description: "Emit new events on new Slack [interactivity events](https://api.slack.com/interactivity) sourced from [Block Kit interactive elements](https://api.slack.com/interactivity/components), [Slash commands](https://api.slack.com/interactivity/slash-commands), or [Shortcuts](https://api.slack.com/interactivity/shortcuts).",
|
|
9
9
|
type: "source",
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
...common,
|
|
7
7
|
key: "slack-new-keyword-mention",
|
|
8
8
|
name: "New Keyword Mention (Instant)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.7",
|
|
10
10
|
description: "Emit new event when a specific keyword is mentioned in a channel",
|
|
11
11
|
type: "source",
|
|
12
12
|
dedupe: "unique",
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
...common,
|
|
7
7
|
key: "slack-new-message-in-channels",
|
|
8
8
|
name: "New Message In Channels (Instant)",
|
|
9
|
-
version: "1.0.
|
|
9
|
+
version: "1.0.24",
|
|
10
10
|
description: "Emit new event when a new message is posted to one or more channels",
|
|
11
11
|
type: "source",
|
|
12
12
|
dedupe: "unique",
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
...common,
|
|
6
6
|
key: "slack-new-reaction-added",
|
|
7
7
|
name: "New Reaction Added (Instant)",
|
|
8
|
-
version: "1.1.
|
|
8
|
+
version: "1.1.25",
|
|
9
9
|
description: "Emit new event when a member has added an emoji reaction to a message",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|