fix(onebot): make group large-video file fallback actually fire
#153 added a video→file fallback but the group side was dead code: it lived in element-builder behind `isGroup && element.fileId`, and a video sent by url/path has no fileId, so oversize group videos just rethrew the raw Highway error (real bot: `error_code=323` on a 1.4 GB group send). Move the fallback to the OneBot layer for groups, mirroring the private path: on a failed Highway send, re-route oversize videos through groupFile.upload. Verified on a live bot — a 1.4 GB group video now lands as `[文件:video.mp4]` instead of failing. Extract the shared heuristic (isHighwaySizeError / videoNeedsFileFallback / splitVideoFileFallback) so private and group stay in sync, and drop the now-unreachable element-builder video catch. Adds send-video-fallback tests covering both the known-oversize and remote-error-heuristic paths.
This commit is contained in:
3 files changed
+211
-55
No files matched your search
@@ -375,26 +375,22 @@ async function makeVideoElem(ctx: SendContext, element: MessageElement): Promise
|
||||
throw new Error('private video target uid is missing');
|
||||
}
|
||||
|
||||
try {
|
||||
const msgInfo = await uploadVideoMsgInfo(ctx.bridge, isGroup, targetIdOrUid, element);
|
||||
const msgInfo = await uploadVideoMsgInfo(ctx.bridge, isGroup, targetIdOrUid, element);
|
||||
|
||||
// commonElem.businessType is the QQ NT scene tag the receive-side
|
||||
// decoder pairs with: 11=c2c, 21=group. Sending the group tag on a
|
||||
// c2c message bounces with PbSendMsg result=79.
|
||||
return {
|
||||
commonElem: {
|
||||
serviceType: 48,
|
||||
pbElem: msgInfo,
|
||||
businessType: isGroup ? 21 : 11,
|
||||
},
|
||||
};
|
||||
} catch (err) {
|
||||
if (isGroup && element.fileId) {
|
||||
console.warn('[ElemBuilder] video upload failed, falling back to file element: %s', err instanceof Error ? err.message : String(err));
|
||||
return makeGroupFileElem(element, ctx);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
// commonElem.businessType is the QQ NT scene tag the receive-side
|
||||
// decoder pairs with: 11=c2c, 21=group. Sending the group tag on a
|
||||
// c2c message bounces with PbSendMsg result=79.
|
||||
//
|
||||
// Oversize videos throw here; the OneBot layer catches that and falls
|
||||
// back to file upload (see message-actions.ts video fallback). A file
|
||||
// element can't be built here — there's no uploaded file_id yet.
|
||||
return {
|
||||
commonElem: {
|
||||
serviceType: 48,
|
||||
pbElem: msgInfo,
|
||||
businessType: isGroup ? 21 : 11,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user