fix(feishu): use msg_type 'media' for video/audio messages

Feishu API requires msg_type 'media' for audio (opus) and video (mp4)
files, but sendFileFeishu always used 'file'. This caused error 230055
'file upload type does not match message type' when sending videos.

Closes #14638
This commit is contained in:
0xRaini
2026-02-12 21:01:40 +08:00
committed by Peter Steinberger
parent 069670388e
commit a0be7df5e2

View File

@@ -359,10 +359,13 @@ export async function sendFileFeishu(params: {
cfg: ClawdbotConfig;
to: string;
fileKey: string;
/** Use "media" for audio/video files, "file" for documents */
msgType?: "file" | "media";
replyToMessageId?: string;
accountId?: string;
}): Promise<SendMediaResult> {
const { cfg, to, fileKey, replyToMessageId, accountId } = params;
const msgType = params.msgType ?? "file";
const account = resolveFeishuAccount({ cfg, accountId });
if (!account.configured) {
throw new Error(`Feishu account "${account.accountId}" not configured`);
@@ -382,7 +385,7 @@ export async function sendFileFeishu(params: {
path: { message_id: replyToMessageId },
data: {
content,
msg_type: "file",
msg_type: msgType,
},
});
@@ -401,7 +404,7 @@ export async function sendFileFeishu(params: {
data: {
receive_id: receiveId,
content,
msg_type: "file",
msg_type: msgType,
},
});
@@ -524,6 +527,15 @@ export async function sendMediaFeishu(params: {
fileType,
accountId,
});
return sendFileFeishu({ cfg, to, fileKey, replyToMessageId, accountId });
// Feishu requires msg_type "media" for audio/video, "file" for documents
const isMedia = fileType === "mp4" || fileType === "opus";
return sendFileFeishu({
cfg,
to,
fileKey,
msgType: isMedia ? "media" : "file",
replyToMessageId,
accountId,
});
}
}