Skip to content

Commit fc32b4b

Browse files
committed
revert changes to the Slack app and components
1 parent 2ae0dcb commit fc32b4b

File tree

45 files changed

+291
-470
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+291
-470
lines changed

components/slack/actions/add-emoji-reaction/add-emoji-reaction.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-add-emoji-reaction",
55
name: "Add Emoji Reaction",
66
description: "Add an emoji reaction to a message. [See the documentation](https://api.slack.com/methods/reactions.add)",
7-
version: "0.0.17",
7+
version: "0.0.16",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/slack/actions/approve-workflow/approve-workflow.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "slack-approve-workflow",
66
name: "Approve Workflow",
77
description: "Suspend the workflow until approved by a Slack message. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
8-
version: "0.0.6",
8+
version: "0.0.5",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,

components/slack/actions/archive-channel/archive-channel.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "slack-archive-channel",
66
name: "Archive Channel",
77
description: "Archive a channel. [See the documentation](https://api.slack.com/methods/conversations.archive)",
8-
version: "0.0.25",
8+
version: "0.0.24",
99
annotations: {
1010
destructiveHint: true,
1111
openWorldHint: true,

components/slack/actions/common/send-message.mjs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ export default {
99
"as_user",
1010
],
1111
},
12-
addToChannel: {
13-
propDefinition: [
14-
slack,
15-
"addToChannel",
16-
],
17-
},
1812
post_at: {
1913
propDefinition: [
2014
slack,
@@ -187,14 +181,6 @@ export default {
187181
},
188182
},
189183
async run({ $ }) {
190-
const channelId = await this.getChannelId();
191-
192-
if (this.addToChannel) {
193-
await this.slack.maybeAddAppToChannels([
194-
channelId,
195-
]);
196-
}
197-
198184
let blocks = this.blocks;
199185

200186
if (!blocks) {
@@ -230,7 +216,7 @@ export default {
230216

231217
const obj = {
232218
text: this.text,
233-
channel: channelId,
219+
channel: await this.getChannelId(),
234220
attachments: this.attachments,
235221
unfurl_links: this.unfurl_links,
236222
unfurl_media: this.unfurl_media,
@@ -255,7 +241,15 @@ export default {
255241
const { channel } = await this.slack.conversationsInfo({
256242
channel: resp.channel,
257243
});
258-
const channelName = await this.slack.getChannelDisplayName(channel);
244+
let channelName = `#${channel?.name}`;
245+
if (channel.is_im) {
246+
const { profile } = await this.slack.getUserProfile({
247+
user: channel.user,
248+
});
249+
channelName = `@${profile.real_name}`;
250+
} else if (channel.is_mpim) {
251+
channelName = `@${channel.purpose.value}`;
252+
}
259253
$.export("$summary", `Successfully sent a message to ${channelName}`);
260254
return resp;
261255
},

components/slack/actions/create-channel/create-channel.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-create-channel",
55
name: "Create a Channel",
66
description: "Create a new channel. [See the documentation](https://api.slack.com/methods/conversations.create)",
7-
version: "0.0.26",
7+
version: "0.0.25",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/slack/actions/create-reminder/create-reminder.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-create-reminder",
55
name: "Create Reminder",
66
description: "Create a reminder. [See the documentation](https://api.slack.com/methods/reminders.add)",
7-
version: "0.0.26",
7+
version: "0.0.25",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/slack/actions/delete-file/delete-file.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-delete-file",
55
name: "Delete File",
66
description: "Delete a file. [See the documentation](https://api.slack.com/methods/files.delete)",
7-
version: "0.0.25",
7+
version: "0.0.24",
88
annotations: {
99
destructiveHint: true,
1010
openWorldHint: true,

components/slack/actions/delete-message/delete-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-delete-message",
55
name: "Delete Message",
66
description: "Delete a message. [See the documentation](https://api.slack.com/methods/chat.delete)",
7-
version: "0.1.0",
7+
version: "0.0.24",
88
annotations: {
99
destructiveHint: true,
1010
openWorldHint: true,

components/slack/actions/find-message/find-message.mjs

Lines changed: 26 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import slack from "../../slack.app.mjs";
33
export default {
44
key: "slack-find-message",
55
name: "Find Message",
6-
description: "Find a Slack message. [See the documentation](https://api.slack.com/methods/assistant.search.context)",
7-
version: "0.1.0",
6+
description: "Find a Slack message. [See the documentation](https://api.slack.com/methods/search.messages)",
7+
version: "0.0.26",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
@@ -19,11 +19,18 @@ export default {
1919
"query",
2020
],
2121
},
22+
teamId: {
23+
propDefinition: [
24+
slack,
25+
"team",
26+
],
27+
optional: true,
28+
},
2229
maxResults: {
2330
type: "integer",
2431
label: "Max Results",
2532
description: "The maximum number of messages to return",
26-
default: 20,
33+
default: 100,
2734
optional: true,
2835
},
2936
sort: {
@@ -47,161 +54,29 @@ export default {
4754
optional: true,
4855
},
4956
},
50-
methods: {
51-
normalizeAssistantMatch(match) {
52-
if (!match || typeof match !== "object") {
53-
return match;
54-
}
55-
const {
56-
author_user_id: authorUserId,
57-
team_id: teamId,
58-
channel_id: channelId,
59-
message_ts: messageTs,
60-
content,
61-
permalink,
62-
is_author_bot: isAuthorBot,
63-
message,
64-
channel,
65-
...rest
66-
} = match;
67-
const baseMessage = typeof message === "object"
68-
? message
69-
: {};
70-
const channelInfo = channel && typeof channel === "object"
71-
? {
72-
...channel,
73-
id: channel.id || channelId,
74-
}
75-
: channelId
76-
? {
77-
id: channelId,
78-
}
79-
: undefined;
80-
const normalized = {
81-
type: "message",
82-
user: authorUserId,
83-
team: teamId,
84-
ts: messageTs,
85-
text: content,
86-
permalink,
87-
channel: channelInfo,
88-
...baseMessage,
89-
...rest,
90-
};
91-
if (isAuthorBot !== undefined && normalized.is_author_bot === undefined) {
92-
normalized.is_author_bot = isAuthorBot;
93-
}
94-
if (normalized.text == null) {
95-
normalized.text = baseMessage.text || content;
96-
}
97-
if (normalized.ts == null) {
98-
normalized.ts = baseMessage.ts || messageTs;
99-
}
100-
if (!normalized.channel && baseMessage.channel) {
101-
normalized.channel = baseMessage.channel;
102-
} else if (normalized.channel && baseMessage.channel && typeof baseMessage.channel === "object") {
103-
normalized.channel = {
104-
...normalized.channel,
105-
...baseMessage.channel,
106-
};
107-
}
108-
return normalized;
109-
},
110-
async searchWithAssistant(baseParams, maxResults) {
111-
const matches = [];
112-
let cursor;
113-
114-
do {
115-
const response = await this.slack.assistantSearch({
116-
...baseParams,
117-
channel_types: "public_channel,private_channel",
118-
cursor,
119-
});
120-
const messages = (response.results?.messages || [])
121-
.map((item) => this.normalizeAssistantMatch(item));
122-
matches.push(...messages);
123-
cursor = response.response_metadata?.next_cursor;
124-
} while (cursor && matches.length < maxResults);
125-
126-
return matches.slice(0, maxResults);
127-
},
128-
async searchWithSearchMessages(baseParams, maxResults) {
129-
const matches = [];
130-
let page = 1;
131-
const count = Math.min(Math.max(maxResults, 1), 100);
132-
133-
while (matches.length < maxResults) {
134-
const response = await this.slack.searchMessages({
135-
...baseParams,
136-
count,
137-
page,
138-
});
139-
const pageMatches = response.messages?.matches || [];
140-
matches.push(...pageMatches);
141-
142-
if (matches.length >= maxResults) {
143-
break;
144-
}
145-
146-
const pagination = response.messages?.pagination;
147-
const paging = response.messages?.paging;
148-
const hasMore = pagination
149-
? pagination.page < pagination.page_count
150-
: paging
151-
? paging.page < paging.pages
152-
: false;
153-
154-
if (!hasMore) {
155-
break;
156-
}
157-
158-
page += 1;
159-
}
160-
161-
return matches.slice(0, maxResults);
162-
},
163-
shouldFallbackToSearchMessages(error) {
164-
const errorCode = typeof error === "string"
165-
? error
166-
: error?.data?.error || error?.message;
167-
168-
if (!errorCode?.includes("missing_scope")) {
169-
return false;
170-
}
171-
172-
const providedSources = [
173-
error?.data?.provided,
174-
error?.provided,
175-
error?.original?.data?.provided,
176-
].filter(Boolean);
177-
178-
const providedScopes = providedSources
179-
.flatMap((value) => Array.isArray(value)
180-
? value
181-
: String(value).split(","))
182-
.map((scope) => scope.trim())
183-
.filter(Boolean);
184-
185-
return providedScopes.includes("search:read");
186-
},
187-
},
18857
async run({ $ }) {
189-
const maxResults = Math.max(this.maxResults ?? 20, 1);
190-
const baseParams = {
58+
const matches = [];
59+
const params = {
19160
query: this.query,
61+
team_id: this.teamId,
19262
sort: this.sort,
19363
sort_dir: this.sortDirection,
64+
page: 1,
19465
};
195-
let matches;
66+
let hasMore;
19667

197-
try {
198-
matches = await this.searchWithAssistant(baseParams, maxResults);
199-
} catch (error) {
200-
if (this.shouldFallbackToSearchMessages(error)) {
201-
matches = await this.searchWithSearchMessages(baseParams, maxResults);
202-
} else {
203-
throw error;
68+
do {
69+
const { messages } = await this.slack.searchMessages(params);
70+
matches.push(...messages.matches);
71+
if (matches.length >= this.maxResults) {
72+
break;
20473
}
74+
hasMore = messages.matches?.length;
75+
params.page++;
76+
} while (hasMore);
77+
78+
if (matches.length > this.maxResults) {
79+
matches.length = this.maxResults;
20580
}
20681

20782
$.export("$summary", `Found ${matches.length} matching message${matches.length === 1

components/slack/actions/find-user-by-email/find-user-by-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-find-user-by-email",
55
name: "Find User by Email",
66
description: "Find a user by matching against their email. [See the documentation](https://api.slack.com/methods/users.lookupByEmail)",
7-
version: "0.0.25",
7+
version: "0.0.24",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

0 commit comments

Comments
 (0)