mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 08:12:43 +00:00
fix(slack): scope download-file to channel and thread context
This commit is contained in:
@@ -216,6 +216,33 @@ describe("handleSlackAction", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("passes download scope (channel/thread) to downloadSlackFile", async () => {
|
||||
downloadSlackFile.mockResolvedValueOnce(null);
|
||||
|
||||
const result = await handleSlackAction(
|
||||
{
|
||||
action: "downloadFile",
|
||||
fileId: "F123",
|
||||
to: "channel:C1",
|
||||
replyTo: "123.456",
|
||||
},
|
||||
slackConfig(),
|
||||
);
|
||||
|
||||
expect(downloadSlackFile).toHaveBeenCalledWith(
|
||||
"F123",
|
||||
expect.objectContaining({
|
||||
channelId: "C1",
|
||||
threadId: "123.456",
|
||||
}),
|
||||
);
|
||||
expect(result).toEqual(
|
||||
expect.objectContaining({
|
||||
details: expect.objectContaining({ ok: false }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "JSON blocks",
|
||||
|
||||
@@ -290,12 +290,17 @@ export async function handleSlackAction(
|
||||
}
|
||||
case "downloadFile": {
|
||||
const fileId = readStringParam(params, "fileId", { required: true });
|
||||
const channelTarget = readStringParam(params, "channelId") ?? readStringParam(params, "to");
|
||||
const channelId = channelTarget ? resolveSlackChannelId(channelTarget) : undefined;
|
||||
const threadId = readStringParam(params, "threadId") ?? readStringParam(params, "replyTo");
|
||||
const maxBytes = account.config?.mediaMaxMb
|
||||
? account.config.mediaMaxMb * 1024 * 1024
|
||||
: 20 * 1024 * 1024;
|
||||
const downloaded = await downloadSlackFile(fileId, {
|
||||
...readOpts,
|
||||
maxBytes,
|
||||
channelId,
|
||||
threadId: threadId ?? undefined,
|
||||
});
|
||||
if (!downloaded) {
|
||||
return jsonResult({
|
||||
|
||||
Reference in New Issue
Block a user