mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
fix(slack): upload-file silently drops a caption (#121047)
The Slack `upload-file` action accepts `media` as an alias for `filePath`, so a caller can reach it with the same vocabulary used for a media `send`. That vocabulary carries its accompanying text in `caption`, but the upload path read only `initialComment` and `message`, so the text was dropped and the file arrived in the channel with no comment at all. Accept `caption` as the lowest-precedence alias. Explicit `initialComment` still wins, `message` still comes next, and an explicitly empty higher-precedence value stays empty.
This commit is contained in:
@@ -738,6 +738,32 @@ describe("handleSlackMessageAction", () => {
|
||||
initialComment: "path alias",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "maps an upload-file caption to the upload's initial comment",
|
||||
params: {
|
||||
channelId: "C1",
|
||||
media: "/tmp/chart.png",
|
||||
caption: "chart attached",
|
||||
},
|
||||
expected: {
|
||||
filePath: "/tmp/chart.png",
|
||||
initialComment: "chart attached",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "prefers an explicit upload-file initial comment over message and caption",
|
||||
params: {
|
||||
channelId: "C1",
|
||||
media: "/tmp/chart.png",
|
||||
initialComment: "",
|
||||
message: "message text",
|
||||
caption: "caption text",
|
||||
},
|
||||
expected: {
|
||||
filePath: "/tmp/chart.png",
|
||||
initialComment: "",
|
||||
},
|
||||
},
|
||||
])("$name", async ({ params, expected }) => {
|
||||
const invoke = createInvokeSpy();
|
||||
const cfg = slackConfig();
|
||||
|
||||
@@ -358,6 +358,10 @@ export async function handleSlackMessageAction(params: {
|
||||
initialComment:
|
||||
readStringParam(actionParams, "initialComment", { allowEmpty: true }) ??
|
||||
readStringParam(actionParams, "message", { allowEmpty: true }) ??
|
||||
// `media` is accepted as an alias for the file, so a send-shaped call
|
||||
// arrives with its text in `caption`; without this alias that text is
|
||||
// silently dropped instead of becoming the upload's first comment.
|
||||
readStringParam(actionParams, "caption", { allowEmpty: true }) ??
|
||||
"",
|
||||
filename: readStringParam(actionParams, "filename"),
|
||||
title: readStringParam(actionParams, "title"),
|
||||
|
||||
Reference in New Issue
Block a user