Skip to content

Commit 90d7de9

Browse files
Slack - add maxResults to find-message (#16228)
* add maxResults to find-message * pnpm-lock.yaml * add sort props * fix * pnpm-lock.yaml * pnpm-lock.yaml * pnpm-lock.yaml --------- Co-authored-by: Danny Roosevelt <[email protected]>
1 parent c7d4b33 commit 90d7de9

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

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

Lines changed: 37 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,23 +21,59 @@ 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+
},
31+
sort: {
32+
type: "string",
33+
label: "Sort",
34+
description: "Return matches sorted by either `score` or `timestamp`",
35+
options: [
36+
"score",
37+
"timestamp",
38+
],
39+
optional: true,
40+
},
41+
sortDirection: {
42+
type: "string",
43+
label: "Sort Direction",
44+
description: "Sort ascending (asc) or descending (desc)`",
45+
options: [
46+
"desc",
47+
"asc",
48+
],
49+
optional: true,
50+
},
2451
},
2552
async run({ $ }) {
2653
const matches = [];
2754
const params = {
2855
query: this.query,
2956
team_id: this.teamId,
57+
sort: this.sort,
58+
sort_dir: this.sortDirection,
3059
page: 1,
3160
};
3261
let hasMore;
3362

3463
do {
3564
const { messages } = await this.slack.searchMessages(params);
3665
matches.push(...messages.matches);
66+
if (matches.length >= this.maxResults) {
67+
break;
68+
}
3769
hasMore = messages?.length;
3870
params.page++;
3971
} while (hasMore);
4072

73+
if (matches.length > this.maxResults) {
74+
matches.length = this.maxResults;
75+
}
76+
4177
$.export("$summary", `Found ${matches.length} matching message${matches.length === 1
4278
? ""
4379
: "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)