@pipedream/slack_v2 0.8.0 → 1.0.0
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/add-reaction/add-reaction.mjs +1 -1
- package/actions/archive-channel/archive-channel.mjs +3 -10
- package/actions/browse-files/browse-files.mjs +1 -1
- package/actions/common/build-blocks.mjs +44 -106
- package/actions/common/send-message.mjs +5 -59
- package/actions/create-channel/create-channel.mjs +2 -1
- package/actions/create-reminder/create-reminder.mjs +2 -1
- package/actions/delete-file/delete-file.mjs +2 -4
- package/actions/delete-message/delete-message.mjs +7 -6
- package/actions/edit-message/edit-message.mjs +20 -2
- package/actions/find-message/find-message.mjs +2 -1
- package/actions/find-user-by-email/find-user-by-email.mjs +2 -1
- package/actions/find-user-by-id/find-user-by-id.mjs +4 -3
- package/actions/get-channel-details/get-channel-details.mjs +3 -2
- package/actions/get-channel-history/get-channel-history.mjs +3 -3
- package/actions/get-current-user/get-current-user.mjs +3 -2
- package/actions/get-file/get-file.mjs +2 -12
- package/actions/get-thread-replies/get-thread-replies.mjs +1 -1
- package/actions/get-user-details/get-user-details.mjs +1 -1
- package/actions/invite-user-to-channel/invite-user-to-channel.mjs +2 -1
- package/actions/kick-user/kick-user.mjs +2 -12
- package/actions/list-channels/list-channels.mjs +28 -10
- package/actions/list-emojis/list-emojis.mjs +2 -1
- package/actions/list-files/list-files.mjs +6 -11
- package/actions/list-group-conversations/list-group-conversations.mjs +86 -0
- package/actions/list-group-members/list-group-members.mjs +3 -2
- package/actions/list-icon-emoji-options/list-icon-emoji-options.mjs +6 -3
- package/actions/list-members-in-channel/list-members-in-channel.mjs +2 -1
- package/actions/list-messages/list-messages.mjs +2 -1
- package/actions/list-reminder-options/list-reminder-options.mjs +10 -3
- package/actions/list-replies/list-replies.mjs +2 -9
- package/actions/list-teams/list-teams.mjs +88 -0
- package/actions/list-user-group-options/list-user-group-options.mjs +10 -3
- package/actions/list-users/list-users.mjs +2 -1
- package/actions/post-message/post-message.mjs +29 -3
- package/actions/reply-to-a-message/reply-to-a-message.mjs +13 -12
- package/actions/search/search.mjs +1 -1
- package/actions/send-block-kit-message/send-block-kit-message.mjs +2 -1
- package/actions/send-large-message/send-large-message.mjs +2 -1
- package/actions/send-message/send-message.mjs +5 -15
- package/actions/send-message-advanced/send-message-advanced.mjs +46 -4
- package/actions/send-message-to-channel/send-message-to-channel.mjs +10 -10
- package/actions/send-message-to-user-or-group/send-message-to-user-or-group.mjs +4 -9
- package/actions/set-channel-description/set-channel-description.mjs +2 -1
- package/actions/set-channel-topic/set-channel-topic.mjs +2 -1
- package/actions/set-status/set-status.mjs +4 -3
- package/actions/update-group-members/update-group-members.mjs +5 -4
- package/actions/update-message/update-message.mjs +3 -2
- package/actions/update-profile/update-profile.mjs +3 -2
- package/actions/upload-file/upload-file.mjs +7 -2
- package/actions/verify-slack-signature/verify-slack-signature.mjs +4 -3
- package/common/constants.mjs +16 -0
- package/package.json +2 -2
- package/slack_v2.app.mjs +20 -369
- package/sources/new-channel-created/new-channel-created.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-private-channel-created/new-private-channel-created.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_v2.app.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// x-pd-ai: optimized
|
|
2
|
-
import { WebClient } from "@slack/web-api";
|
|
2
|
+
import { WebClient } from "@slack/web-api@8.0.0";
|
|
3
3
|
import constants from "./common/constants.mjs";
|
|
4
4
|
import get from "lodash/get.js";
|
|
5
5
|
import retry from "async-retry";
|
|
@@ -12,305 +12,37 @@ export default {
|
|
|
12
12
|
user: {
|
|
13
13
|
type: "string",
|
|
14
14
|
label: "User",
|
|
15
|
-
description: "
|
|
16
|
-
useQuery: true,
|
|
17
|
-
async options({
|
|
18
|
-
prevContext, channelId, query,
|
|
19
|
-
}) {
|
|
20
|
-
let nameQuery = query
|
|
21
|
-
?.trim()
|
|
22
|
-
.toLowerCase()
|
|
23
|
-
.replace(/^@/, "");
|
|
24
|
-
if (/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(nameQuery ?? "")) {
|
|
25
|
-
try {
|
|
26
|
-
const { user } = await this.lookupUserByEmail({
|
|
27
|
-
email: nameQuery,
|
|
28
|
-
throwRateLimitError: true,
|
|
29
|
-
});
|
|
30
|
-
return {
|
|
31
|
-
options: [
|
|
32
|
-
{
|
|
33
|
-
label: user.profile?.real_name || user.name,
|
|
34
|
-
value: user.id,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
};
|
|
38
|
-
} catch {
|
|
39
|
-
// Token may lack `users:read.email`, or no member has this email.
|
|
40
|
-
// Fall back to matching names below with the email's local part.
|
|
41
|
-
nameQuery = nameQuery.split("@")[0].replace(/[._-]+/g, " ");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
let channelMembers;
|
|
45
|
-
if (channelId) {
|
|
46
|
-
const { members } = await this.listChannelMembers({
|
|
47
|
-
channel: channelId,
|
|
48
|
-
throwRateLimitError: true,
|
|
49
|
-
});
|
|
50
|
-
channelMembers = new Set(members);
|
|
51
|
-
}
|
|
52
|
-
const options = [];
|
|
53
|
-
let cursor = prevContext?.cursor;
|
|
54
|
-
let pages = 0;
|
|
55
|
-
do {
|
|
56
|
-
const {
|
|
57
|
-
members,
|
|
58
|
-
response_metadata: { next_cursor: nextCursor },
|
|
59
|
-
} = await this.usersList({
|
|
60
|
-
limit: constants.LIMIT,
|
|
61
|
-
cursor,
|
|
62
|
-
throwRateLimitError: true,
|
|
63
|
-
});
|
|
64
|
-
for (const member of members) {
|
|
65
|
-
const isSelectable = !member.deleted
|
|
66
|
-
&& !member.is_bot
|
|
67
|
-
&& member.id !== "USLACKBOT"
|
|
68
|
-
&& (!channelMembers || channelMembers.has(member.id));
|
|
69
|
-
if (isSelectable) {
|
|
70
|
-
const names = [
|
|
71
|
-
member.profile?.real_name,
|
|
72
|
-
member.profile?.display_name,
|
|
73
|
-
member.name,
|
|
74
|
-
];
|
|
75
|
-
if (!nameQuery || names.some((name) => name?.toLowerCase().includes(nameQuery))) {
|
|
76
|
-
options.push({
|
|
77
|
-
label: names.find(Boolean) ?? member.id,
|
|
78
|
-
value: member.id,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
cursor = nextCursor;
|
|
84
|
-
} while (cursor
|
|
85
|
-
&& options.length < constants.LIMIT
|
|
86
|
-
&& ++pages < constants.MAX_NAME_LOOKUP_PAGES);
|
|
87
|
-
return {
|
|
88
|
-
options,
|
|
89
|
-
context: {
|
|
90
|
-
cursor,
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
},
|
|
15
|
+
description: "The user's ID (e.g. `U1234567890`). Use **Find User by Email** to resolve an ID from an email address, or **List Users** to browse all users.",
|
|
94
16
|
},
|
|
95
17
|
group: {
|
|
96
18
|
type: "string",
|
|
97
19
|
label: "Group",
|
|
98
|
-
description: "
|
|
99
|
-
async options({ prevContext }) {
|
|
100
|
-
let { cursor } = prevContext;
|
|
101
|
-
const types = [
|
|
102
|
-
"mpim",
|
|
103
|
-
];
|
|
104
|
-
const resp = await this.availableConversations(types.join(), cursor, true);
|
|
105
|
-
return {
|
|
106
|
-
options: resp.conversations.map((c) => {
|
|
107
|
-
return {
|
|
108
|
-
label: c.purpose.value,
|
|
109
|
-
value: c.id,
|
|
110
|
-
};
|
|
111
|
-
}),
|
|
112
|
-
context: {
|
|
113
|
-
cursor: resp.cursor,
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
},
|
|
20
|
+
description: "The ID of a multi-person direct message (group DM) conversation (e.g. `G1234567890`). Use **List Group Conversations** to find valid IDs.",
|
|
117
21
|
},
|
|
118
22
|
userGroup: {
|
|
119
23
|
type: "string",
|
|
120
24
|
label: "User Group",
|
|
121
|
-
description: "The encoded ID of the User Group.",
|
|
122
|
-
async options() {
|
|
123
|
-
const { usergroups } = await this.usergroupsList({
|
|
124
|
-
throwRateLimitError: true,
|
|
125
|
-
});
|
|
126
|
-
return usergroups.map((c) => ({
|
|
127
|
-
label: c.name,
|
|
128
|
-
value: c.id,
|
|
129
|
-
}));
|
|
130
|
-
},
|
|
25
|
+
description: "The encoded ID of the User Group (e.g. `S1234567890`). Use **List User Group Options** to find valid IDs.",
|
|
131
26
|
},
|
|
132
27
|
reminder: {
|
|
133
28
|
type: "string",
|
|
134
29
|
label: "Reminder",
|
|
135
|
-
description: "
|
|
136
|
-
async options() {
|
|
137
|
-
const { reminders } = await this.remindersList({
|
|
138
|
-
throwRateLimitError: true,
|
|
139
|
-
});
|
|
140
|
-
return reminders.map((c) => ({
|
|
141
|
-
label: c.text,
|
|
142
|
-
value: c.id,
|
|
143
|
-
}));
|
|
144
|
-
},
|
|
30
|
+
description: "The encoded ID of the reminder (e.g. `Rm1234567890`). Use **List Reminder Options** to find valid IDs.",
|
|
145
31
|
},
|
|
146
32
|
conversation: {
|
|
147
33
|
type: "string",
|
|
148
34
|
label: "Channel",
|
|
149
|
-
description: "
|
|
150
|
-
async options({
|
|
151
|
-
prevContext, types,
|
|
152
|
-
}) {
|
|
153
|
-
let { cursor } = prevContext;
|
|
154
|
-
if (prevContext?.types) {
|
|
155
|
-
types = prevContext.types;
|
|
156
|
-
}
|
|
157
|
-
if (types == null) {
|
|
158
|
-
const { response_metadata: { scopes } } = await this.authTest({
|
|
159
|
-
throwRateLimitError: true,
|
|
160
|
-
});
|
|
161
|
-
types = [
|
|
162
|
-
"public_channel",
|
|
163
|
-
];
|
|
164
|
-
if (scopes.includes("groups:read")) {
|
|
165
|
-
types.push("private_channel");
|
|
166
|
-
}
|
|
167
|
-
if (scopes.includes("mpim:read")) {
|
|
168
|
-
types.push("mpim");
|
|
169
|
-
}
|
|
170
|
-
if (scopes.includes("im:read")) {
|
|
171
|
-
types.push("im");
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
const conversationsResp = await this.availableConversations(types.join(), cursor, true);
|
|
175
|
-
let conversations, userIds, userNames, realNames;
|
|
176
|
-
if (types.includes("im")) {
|
|
177
|
-
conversations = conversationsResp.conversations;
|
|
178
|
-
userIds = conversations.map(({ user }) => user).filter(Boolean);
|
|
179
|
-
} else {
|
|
180
|
-
conversations = conversationsResp.conversations.filter((c) => !c.is_im);
|
|
181
|
-
}
|
|
182
|
-
if (types.includes("mpim")) {
|
|
183
|
-
userNames = [
|
|
184
|
-
...new Set(conversations.filter((c) => c.is_mpim).map((c) => c.purpose.value)
|
|
185
|
-
.map((v) => v.match(/@[\w.-]+/g) || [])
|
|
186
|
-
.flat()
|
|
187
|
-
.map((u) => u.slice(1))),
|
|
188
|
-
];
|
|
189
|
-
}
|
|
190
|
-
if ((userIds?.length > 0) || (userNames?.length > 0)) {
|
|
191
|
-
// Look up real names for userIds and userNames at the same time to
|
|
192
|
-
// minimize number of API calls.
|
|
193
|
-
realNames = await this.realNameLookup(userIds, userNames);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return {
|
|
197
|
-
options: conversations.map((c) => {
|
|
198
|
-
if (c.is_im) {
|
|
199
|
-
return {
|
|
200
|
-
label: `Direct messaging with: ${realNames?.[c.user] ?? c.user}`,
|
|
201
|
-
value: c.id,
|
|
202
|
-
};
|
|
203
|
-
} else if (c.is_mpim) {
|
|
204
|
-
const usernames = c.purpose.value.match(/@[\w.-]+/g) || [];
|
|
205
|
-
const realnames = usernames.map((u) => realNames?.[u.slice(1)] || u);
|
|
206
|
-
return {
|
|
207
|
-
label: realnames.length
|
|
208
|
-
? `Group messaging with: ${realnames.join(", ")}`
|
|
209
|
-
: c.purpose.value,
|
|
210
|
-
value: c.id,
|
|
211
|
-
};
|
|
212
|
-
} else {
|
|
213
|
-
return {
|
|
214
|
-
label: `${c.is_private
|
|
215
|
-
? "Private"
|
|
216
|
-
: "Public"} channel: ${c.name}`,
|
|
217
|
-
value: c.id,
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
}),
|
|
221
|
-
context: {
|
|
222
|
-
types,
|
|
223
|
-
cursor: conversationsResp.cursor,
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
},
|
|
35
|
+
description: "A channel ID (e.g. `C1234567890`), or, depending on the action, a user ID (opens a direct message) or a group DM ID. Use **List Channels** to look up channel IDs, **Find User by Email** / **Find User by ID** to resolve a user ID, or **List Group Conversations** for group DM IDs.",
|
|
227
36
|
},
|
|
228
37
|
channelId: {
|
|
229
38
|
type: "string",
|
|
230
39
|
label: "Channel ID",
|
|
231
|
-
description: "
|
|
232
|
-
async options({
|
|
233
|
-
prevContext,
|
|
234
|
-
types = Object.values(constants.CHANNEL_TYPE),
|
|
235
|
-
channelsFilter = (channel) => channel,
|
|
236
|
-
excludeArchived = true,
|
|
237
|
-
}) {
|
|
238
|
-
const {
|
|
239
|
-
channels,
|
|
240
|
-
response_metadata: { next_cursor: cursor },
|
|
241
|
-
} = await this.conversationsList({
|
|
242
|
-
types: types.join(),
|
|
243
|
-
cursor: prevContext.cursor,
|
|
244
|
-
limit: constants.LIMIT,
|
|
245
|
-
exclude_archived: excludeArchived,
|
|
246
|
-
throwRateLimitError: true,
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
let userNames;
|
|
250
|
-
if (types.includes("im")) {
|
|
251
|
-
const userIds = channels.filter(({ is_im }) => is_im).map(({ user }) => user);
|
|
252
|
-
userNames = await this.userNameLookup(userIds);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const options = channels
|
|
256
|
-
.filter(channelsFilter)
|
|
257
|
-
.map((c) => {
|
|
258
|
-
if (c.is_im) {
|
|
259
|
-
const userName = userNames?.[c.user];
|
|
260
|
-
return {
|
|
261
|
-
label: `Direct messaging with: ${userName
|
|
262
|
-
? `@${userName}`
|
|
263
|
-
: c.user}`,
|
|
264
|
-
value: c.id,
|
|
265
|
-
};
|
|
266
|
-
} else if (c.is_mpim) {
|
|
267
|
-
return {
|
|
268
|
-
label: c.purpose.value,
|
|
269
|
-
value: c.id,
|
|
270
|
-
};
|
|
271
|
-
} else {
|
|
272
|
-
return {
|
|
273
|
-
label: `${c.is_private
|
|
274
|
-
? "Private"
|
|
275
|
-
: "Public"} channel: ${c.name}`,
|
|
276
|
-
value: c.id,
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
return {
|
|
282
|
-
options,
|
|
283
|
-
context: {
|
|
284
|
-
cursor,
|
|
285
|
-
},
|
|
286
|
-
};
|
|
287
|
-
},
|
|
40
|
+
description: "The channel's ID (e.g. `C1234567890`). Use **List Channels** to find valid IDs.",
|
|
288
41
|
},
|
|
289
42
|
team: {
|
|
290
43
|
type: "string",
|
|
291
44
|
label: "Team",
|
|
292
|
-
description: "
|
|
293
|
-
async options({ prevContext }) {
|
|
294
|
-
const {
|
|
295
|
-
teams,
|
|
296
|
-
response_metadata: { next_cursor: cursor },
|
|
297
|
-
} = await this.authTeamsList({
|
|
298
|
-
cursor: prevContext.cursor,
|
|
299
|
-
limit: constants.LIMIT,
|
|
300
|
-
throwRateLimitError: true,
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
return {
|
|
304
|
-
options: teams.map((team) => ({
|
|
305
|
-
label: team.name,
|
|
306
|
-
value: team.id,
|
|
307
|
-
})),
|
|
308
|
-
|
|
309
|
-
context: {
|
|
310
|
-
cursor,
|
|
311
|
-
},
|
|
312
|
-
};
|
|
313
|
-
},
|
|
45
|
+
description: "The encoded team ID (e.g. `T1234567890`). Only required when the connected token spans multiple teams (Enterprise Grid); omit otherwise. Use **List Teams** to find valid IDs.",
|
|
314
46
|
},
|
|
315
47
|
messageTs: {
|
|
316
48
|
type: "string",
|
|
@@ -325,38 +57,22 @@ export default {
|
|
|
325
57
|
topic: {
|
|
326
58
|
type: "string",
|
|
327
59
|
label: "Topic",
|
|
328
|
-
description: "
|
|
60
|
+
description: "The new topic text to display in the channel header (e.g. `Q3 roadmap discussion`). Slack truncates topics longer than 250 characters.",
|
|
329
61
|
},
|
|
330
62
|
purpose: {
|
|
331
63
|
type: "string",
|
|
332
64
|
label: "Purpose",
|
|
333
|
-
description: "
|
|
65
|
+
description: "The new purpose/description text for the channel, shown in the channel details panel (e.g. `Channel for engineering incident coordination`). Limited to 250 characters by Slack.",
|
|
334
66
|
},
|
|
335
67
|
query: {
|
|
336
68
|
type: "string",
|
|
337
69
|
label: "Query",
|
|
338
|
-
description: "
|
|
70
|
+
description: "The search query. Supports Slack search modifiers, e.g. `from:@user`, `in:#channel`, `before:2025-01-01`, `has:link`. Combine terms and modifiers as needed, e.g. `budget in:#finance from:@jane`.",
|
|
339
71
|
},
|
|
340
72
|
file: {
|
|
341
73
|
type: "string",
|
|
342
74
|
label: "File ID",
|
|
343
|
-
description: "
|
|
344
|
-
async options({
|
|
345
|
-
channel, page,
|
|
346
|
-
}) {
|
|
347
|
-
const { files } = await this.listFiles({
|
|
348
|
-
channel,
|
|
349
|
-
page: page + 1,
|
|
350
|
-
count: constants.LIMIT,
|
|
351
|
-
throwRateLimitError: true,
|
|
352
|
-
});
|
|
353
|
-
return files?.map(({
|
|
354
|
-
id: value, name: label,
|
|
355
|
-
}) => ({
|
|
356
|
-
value,
|
|
357
|
-
label,
|
|
358
|
-
})) || [];
|
|
359
|
-
},
|
|
75
|
+
description: "The file's ID (e.g. `F1234567890`). Use **List Files** to find valid IDs.",
|
|
360
76
|
},
|
|
361
77
|
attachments: {
|
|
362
78
|
type: "string",
|
|
@@ -419,13 +135,8 @@ export default {
|
|
|
419
135
|
icon_emoji: {
|
|
420
136
|
type: "string",
|
|
421
137
|
label: "Icon (emoji)",
|
|
422
|
-
description: "Optionally provide an emoji to use as the icon for this message. E.g., `:fire
|
|
138
|
+
description: "Optionally provide an emoji to use as the icon for this message, wrapped in colons. E.g., `:fire:`. Overrides `icon_url`. Must be used in conjunction with `Send as User` set to `false`, otherwise ignored. Use **List Icon (emoji) Options** to look up valid emoji names for this workspace, including custom emoji.",
|
|
423
139
|
optional: true,
|
|
424
|
-
async options() {
|
|
425
|
-
return await this.getCustomEmojis({
|
|
426
|
-
throwRateLimitError: true,
|
|
427
|
-
});
|
|
428
|
-
},
|
|
429
140
|
},
|
|
430
141
|
content: {
|
|
431
142
|
label: "File Path or URL",
|
|
@@ -436,7 +147,7 @@ export default {
|
|
|
436
147
|
link_names: {
|
|
437
148
|
type: "boolean",
|
|
438
149
|
label: "Link Names",
|
|
439
|
-
description: "
|
|
150
|
+
description: "If `true`, automatically converts plain-text `@name` and `#channel` mentions in `text` into linked Slack mentions. If `false` (default), mentions are left as plain text and won't notify or link. Has no effect when using `blocks`.",
|
|
440
151
|
optional: true,
|
|
441
152
|
},
|
|
442
153
|
thread_broadcast: {
|
|
@@ -520,6 +231,12 @@ export default {
|
|
|
520
231
|
default: 1,
|
|
521
232
|
optional: true,
|
|
522
233
|
},
|
|
234
|
+
cursor: {
|
|
235
|
+
type: "string",
|
|
236
|
+
label: "Cursor",
|
|
237
|
+
description: "Resume from a previous call's `next_cursor` to fetch the following page.",
|
|
238
|
+
optional: true,
|
|
239
|
+
},
|
|
523
240
|
addToChannel: {
|
|
524
241
|
type: "boolean",
|
|
525
242
|
label: "Add app to channel automatically?",
|
|
@@ -652,34 +369,6 @@ export default {
|
|
|
652
369
|
}
|
|
653
370
|
}, retryOpts);
|
|
654
371
|
},
|
|
655
|
-
/**
|
|
656
|
-
* Returns a list of channel-like conversations in a workspace. The
|
|
657
|
-
* "channels" returned depend on what the calling token has access to and
|
|
658
|
-
* the directives placed in the types parameter.
|
|
659
|
-
*
|
|
660
|
-
* @param {string} [types] - a comma-separated list of channel types to get.
|
|
661
|
-
* Any combination of: `public_channel`, `private_channel`, `mpim`, `im`
|
|
662
|
-
* @param {string} [cursor] - a cursor returned by the previous API call,
|
|
663
|
-
* used to paginate through collections of data
|
|
664
|
-
* @returns an object containing a list of conversations and the cursor for the next
|
|
665
|
-
* page of conversations
|
|
666
|
-
*/
|
|
667
|
-
async availableConversations(types, cursor, throwRateLimitError = false) {
|
|
668
|
-
const {
|
|
669
|
-
channels: conversations,
|
|
670
|
-
response_metadata: { next_cursor: nextCursor },
|
|
671
|
-
} = await this.usersConversations({
|
|
672
|
-
types,
|
|
673
|
-
cursor,
|
|
674
|
-
limit: constants.LIMIT,
|
|
675
|
-
exclude_archived: true,
|
|
676
|
-
throwRateLimitError,
|
|
677
|
-
});
|
|
678
|
-
return {
|
|
679
|
-
cursor: nextCursor,
|
|
680
|
-
conversations,
|
|
681
|
-
};
|
|
682
|
-
},
|
|
683
372
|
// Resolves user names by scanning `users.list`, capped at
|
|
684
373
|
// MAX_NAME_LOOKUP_PAGES pages per call: some ids may be unresolvable
|
|
685
374
|
// (e.g. external Slack Connect users), so callers must handle missing
|
|
@@ -711,44 +400,6 @@ export default {
|
|
|
711
400
|
&& Object.keys(userNames).length < ids.length);
|
|
712
401
|
return userNames;
|
|
713
402
|
},
|
|
714
|
-
// Resolves real names by scanning `users.list`, capped at
|
|
715
|
-
// MAX_NAME_LOOKUP_PAGES pages per call: some ids/usernames may be
|
|
716
|
-
// unresolvable (e.g. external Slack Connect users, or stale usernames in
|
|
717
|
-
// mpim purpose text), so callers must handle missing entries in the
|
|
718
|
-
// result.
|
|
719
|
-
async realNameLookup(ids = [], usernames = [], throwRateLimitError = true, args = {}) {
|
|
720
|
-
const idSet = new Set(ids);
|
|
721
|
-
const usernameSet = new Set(usernames);
|
|
722
|
-
let cursor;
|
|
723
|
-
let pages = 0;
|
|
724
|
-
const realNames = {};
|
|
725
|
-
const targetCount = ids.length + usernames.length;
|
|
726
|
-
do {
|
|
727
|
-
const {
|
|
728
|
-
members: users,
|
|
729
|
-
response_metadata: { next_cursor: nextCursor },
|
|
730
|
-
} = await this.usersList({
|
|
731
|
-
limit: constants.LIMIT,
|
|
732
|
-
cursor,
|
|
733
|
-
throwRateLimitError,
|
|
734
|
-
...args,
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
for (const user of users) {
|
|
738
|
-
if (idSet.has(user.id)) {
|
|
739
|
-
realNames[user.id] = user.profile.real_name;
|
|
740
|
-
}
|
|
741
|
-
if (usernameSet.has(user.name)) {
|
|
742
|
-
realNames[user.name] = user.profile.real_name;
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
cursor = nextCursor;
|
|
747
|
-
} while (cursor
|
|
748
|
-
&& ++pages < constants.MAX_NAME_LOOKUP_PAGES
|
|
749
|
-
&& Object.keys(realNames).length < targetCount);
|
|
750
|
-
return realNames;
|
|
751
|
-
},
|
|
752
403
|
async maybeAddAppToChannels(channelIds = []) {
|
|
753
404
|
if (!this.getBotToken()) {
|
|
754
405
|
console.log("Skipping adding app to channels: bot unavailable.");
|
|
@@ -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.28",
|
|
7
7
|
key: "slack_v2-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",
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
...common,
|
|
8
8
|
key: "slack_v2-new-keyword-mention",
|
|
9
9
|
name: "New Keyword Mention (Instant)",
|
|
10
|
-
version: "0.1.
|
|
10
|
+
version: "0.1.7",
|
|
11
11
|
description: "Emit new event when a specific keyword is mentioned in a channel",
|
|
12
12
|
type: "source",
|
|
13
13
|
dedupe: "unique",
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
...common,
|
|
8
8
|
key: "slack_v2-new-message-in-channels",
|
|
9
9
|
name: "New Message In Channels (Instant)",
|
|
10
|
-
version: "1.1.
|
|
10
|
+
version: "1.1.7",
|
|
11
11
|
description: "Emit new event when a new message is posted to one or more channels",
|
|
12
12
|
type: "source",
|
|
13
13
|
dedupe: "unique",
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
...common,
|
|
5
5
|
key: "slack_v2-new-private-channel-created",
|
|
6
6
|
name: "New Private Channel Created",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
description: "Emit new event when a new private channel is created. [See the documentation](https://api.slack.com/methods/conversations.list)",
|
|
9
9
|
type: "source",
|
|
10
10
|
dedupe: "unique",
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
...common,
|
|
6
6
|
key: "slack_v2-new-reaction-added",
|
|
7
7
|
name: "New Reaction Added (Instant)",
|
|
8
|
-
version: "1.2.
|
|
8
|
+
version: "1.2.7",
|
|
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",
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
...common,
|
|
6
6
|
key: "slack_v2-new-saved-message",
|
|
7
7
|
name: "New Saved Message (Instant)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.13",
|
|
9
9
|
description: "Emit new event when a message is saved. Note: The endpoint is marked as deprecated, and Slack might shut this off at some point down the line.",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
...common,
|
|
8
8
|
key: "slack_v2-new-user-mention",
|
|
9
9
|
name: "New User Mention (Instant)",
|
|
10
|
-
version: "0.1.
|
|
10
|
+
version: "0.1.7",
|
|
11
11
|
description: "Emit new event when a username or specific keyword is mentioned in a channel",
|
|
12
12
|
type: "source",
|
|
13
13
|
dedupe: "unique",
|