mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 09:02:45 +00:00
fix(slack): apply limit parameter to emoji-list action (#13421)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 67e9b64858
Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com>
Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
Reviewed-by: @steipete
This commit is contained in:
@@ -18,7 +18,13 @@ import {
|
||||
} from "../../slack/actions.js";
|
||||
import { parseSlackTarget, resolveSlackChannelId } from "../../slack/targets.js";
|
||||
import { withNormalizedTimestamp } from "../date-time.js";
|
||||
import { createActionGate, jsonResult, readReactionParams, readStringParam } from "./common.js";
|
||||
import {
|
||||
createActionGate,
|
||||
jsonResult,
|
||||
readNumberParam,
|
||||
readReactionParams,
|
||||
readStringParam,
|
||||
} from "./common.js";
|
||||
|
||||
const messagingActions = new Set(["sendMessage", "editMessage", "deleteMessage", "readMessages"]);
|
||||
|
||||
@@ -305,8 +311,18 @@ export async function handleSlackAction(
|
||||
if (!isActionEnabled("emojiList")) {
|
||||
throw new Error("Slack emoji list is disabled.");
|
||||
}
|
||||
const emojis = readOpts ? await listSlackEmojis(readOpts) : await listSlackEmojis();
|
||||
return jsonResult({ ok: true, emojis });
|
||||
const result = readOpts ? await listSlackEmojis(readOpts) : await listSlackEmojis();
|
||||
const limit = readNumberParam(params, "limit", { integer: true });
|
||||
if (limit != null && limit > 0 && result.emoji != null) {
|
||||
const entries = Object.entries(result.emoji).toSorted(([a], [b]) => a.localeCompare(b));
|
||||
if (entries.length > limit) {
|
||||
return jsonResult({
|
||||
ok: true,
|
||||
emojis: { ...result, emoji: Object.fromEntries(entries.slice(0, limit)) },
|
||||
});
|
||||
}
|
||||
}
|
||||
return jsonResult({ ok: true, emojis: result });
|
||||
}
|
||||
|
||||
throw new Error(`Unknown action: ${action}`);
|
||||
|
||||
Reference in New Issue
Block a user