Skip to content

Commit 595885d

Browse files
committed
add maxResults to find-message
1 parent 4dbe682 commit 595885d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-find-message",
55
name: "Find Message",
66
description: "Find a Slack message. [See the documentation](https://api.slack.com/methods/search.messages)",
7-
version: "0.0.23",
7+
version: "0.0.24",
88
type: "action",
99
props: {
1010
slack,
@@ -21,6 +21,13 @@ export default {
2121
],
2222
optional: true,
2323
},
24+
maxResults: {
25+
type: "integer",
26+
label: "Max Results",
27+
description: "The maximum number of messages to return",
28+
default: 100,
29+
optional: true,
30+
},
2431
},
2532
async run({ $ }) {
2633
const matches = [];
@@ -34,10 +41,17 @@ export default {
3441
do {
3542
const { messages } = await this.slack.searchMessages(params);
3643
matches.push(...messages.matches);
44+
if (messages.length >= this.maxResults) {
45+
break;
46+
}
3747
hasMore = messages?.length;
3848
params.page++;
3949
} while (hasMore);
4050

51+
if (matches.length > this.maxResults) {
52+
matches.length = this.maxResults;
53+
}
54+
4155
$.export("$summary", `Found ${matches.length} matching message${matches.length === 1
4256
? ""
4357
: "s"}`);

components/slack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/slack",
3-
"version": "0.9.2",
3+
"version": "0.9.3",
44
"description": "Pipedream Slack Components",
55
"main": "slack.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)