Slack: reject blocks plus media in send paths

This commit is contained in:
Colin
2026-02-16 12:33:43 -05:00
committed by Peter Steinberger
parent 10d876e319
commit c943ffab7c
4 changed files with 41 additions and 0 deletions

View File

@@ -221,6 +221,21 @@ describe("handleSlackAction", () => {
).rejects.toThrow(/requires content, blocks, or mediaUrl/i);
});
it("rejects blocks combined with mediaUrl", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as OpenClawConfig;
await expect(
handleSlackAction(
{
action: "sendMessage",
to: "channel:C123",
blocks: [{ type: "divider" }],
mediaUrl: "https://example.com/image.png",
},
cfg,
),
).rejects.toThrow(/does not support blocks with mediaUrl/i);
});
it("passes blocks JSON to editSlackMessage with empty content", async () => {
const cfg = { channels: { slack: { botToken: "tok" } } } as OpenClawConfig;
editSlackMessage.mockClear();

View File

@@ -185,6 +185,9 @@ export async function handleSlackAction(
if (!content && !mediaUrl && !blocks) {
throw new Error("Slack sendMessage requires content, blocks, or mediaUrl.");
}
if (mediaUrl && blocks) {
throw new Error("Slack sendMessage does not support blocks with mediaUrl.");
}
const threadTs = resolveThreadTsFromContext(
readStringParam(params, "threadTs"),
to,