fix(feishu): handle message_type "media" for video downloads (openclaw#25502) thanks @4ier

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: 4ier <5648066+4ier@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
傅洋
2026-02-28 12:28:37 +08:00
committed by GitHub
parent d9230b13a4
commit e4cb6a88be
3 changed files with 53 additions and 2 deletions

View File

@@ -571,6 +571,54 @@ describe("handleFeishuMessage command authorization", () => {
);
});
it("uses media message_type file_key (not thumbnail image_key) for inbound mobile video download", async () => {
mockShouldComputeCommandAuthorized.mockReturnValue(false);
const cfg: ClawdbotConfig = {
channels: {
feishu: {
dmPolicy: "open",
},
},
} as ClawdbotConfig;
const event: FeishuMessageEvent = {
sender: {
sender_id: {
open_id: "ou-sender",
},
},
message: {
message_id: "msg-media-inbound",
chat_id: "oc-dm",
chat_type: "p2p",
message_type: "media",
content: JSON.stringify({
file_key: "file_media_payload",
image_key: "img_media_thumb",
file_name: "mobile.mp4",
}),
},
};
await dispatchMessage({ cfg, event });
expect(mockDownloadMessageResourceFeishu).toHaveBeenCalledWith(
expect.objectContaining({
messageId: "msg-media-inbound",
fileKey: "file_media_payload",
type: "file",
}),
);
expect(mockSaveMediaBuffer).toHaveBeenCalledWith(
expect.any(Buffer),
"video/mp4",
"inbound",
expect.any(Number),
"clip.mp4",
);
});
it("includes message_id in BodyForAgent on its own line", async () => {
mockShouldComputeCommandAuthorized.mockReturnValue(false);

View File

@@ -371,7 +371,8 @@ function parseMediaKeys(
case "audio":
return { fileKey };
case "video":
// Video has both file_key (video) and image_key (thumbnail)
case "media":
// Video/media has both file_key (video) and image_key (thumbnail)
return { fileKey, imageKey };
case "sticker":
return { fileKey };
@@ -471,6 +472,7 @@ function inferPlaceholder(messageType: string): string {
case "audio":
return "<media:audio>";
case "video":
case "media":
return "<media:video>";
case "sticker":
return "<media:sticker>";
@@ -495,7 +497,7 @@ async function resolveFeishuMediaList(params: {
const { cfg, messageId, messageType, content, maxBytes, log, accountId } = params;
// Only process media message types (including post for embedded images)
const mediaTypes = ["image", "file", "audio", "video", "sticker", "post"];
const mediaTypes = ["image", "file", "audio", "video", "media", "sticker", "post"];
if (!mediaTypes.includes(messageType)) {
return [];
}