mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 07:07:27 +00:00
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:
committed by
Peter Steinberger
parent
069670388e
commit
a0be7df5e2
@@ -359,10 +359,13 @@ export async function sendFileFeishu(params: {
|
|||||||
cfg: ClawdbotConfig;
|
cfg: ClawdbotConfig;
|
||||||
to: string;
|
to: string;
|
||||||
fileKey: string;
|
fileKey: string;
|
||||||
|
/** Use "media" for audio/video files, "file" for documents */
|
||||||
|
msgType?: "file" | "media";
|
||||||
replyToMessageId?: string;
|
replyToMessageId?: string;
|
||||||
accountId?: string;
|
accountId?: string;
|
||||||
}): Promise<SendMediaResult> {
|
}): Promise<SendMediaResult> {
|
||||||
const { cfg, to, fileKey, replyToMessageId, accountId } = params;
|
const { cfg, to, fileKey, replyToMessageId, accountId } = params;
|
||||||
|
const msgType = params.msgType ?? "file";
|
||||||
const account = resolveFeishuAccount({ cfg, accountId });
|
const account = resolveFeishuAccount({ cfg, accountId });
|
||||||
if (!account.configured) {
|
if (!account.configured) {
|
||||||
throw new Error(`Feishu account "${account.accountId}" not configured`);
|
throw new Error(`Feishu account "${account.accountId}" not configured`);
|
||||||
@@ -382,7 +385,7 @@ export async function sendFileFeishu(params: {
|
|||||||
path: { message_id: replyToMessageId },
|
path: { message_id: replyToMessageId },
|
||||||
data: {
|
data: {
|
||||||
content,
|
content,
|
||||||
msg_type: "file",
|
msg_type: msgType,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -401,7 +404,7 @@ export async function sendFileFeishu(params: {
|
|||||||
data: {
|
data: {
|
||||||
receive_id: receiveId,
|
receive_id: receiveId,
|
||||||
content,
|
content,
|
||||||
msg_type: "file",
|
msg_type: msgType,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -524,6 +527,15 @@ export async function sendMediaFeishu(params: {
|
|||||||
fileType,
|
fileType,
|
||||||
accountId,
|
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,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user