fix(video): carry real width/height on group video sends (#145)

A group video uploaded with fileInfo width/height = 0x0 reaches receivers
as 文件已过期 even though the resource is fresh and downloadable: QQ-NT
clients (Android especially) can't lay out the video tile without real
dimensions, so they render the expired placeholder. iOS is lenient — it
shows the expired badge but still opens the video, which is exactly the
"iOS 显示过期可以点开、安卓过期点不开" split users reported.

Real-machine capture on tempserver confirmed a working QQ group video's
MsgInfo carries real dimensions (e.g. 296x640) while ours sent 0x0. Fill
width/height from the probed video for group sends; c2c stays at 0 because
the QQ-NT server rejects non-zero dimensions there with a schema mismatch
(no c2c regression coverage yet). Verified end-to-end: a fresh 11 MB group
video that rendered 已过期 now displays and plays.
This commit is contained in:
DrSmoothl committed 2026-07-04 23:15:03 +08:00
1 parent efac547d6a
commit 9a6c17cb27
2 files changed
+27 -7

No files matched your search

@@ -100,6 +100,23 @@ describe('video-upload', () => {
expect((uploadInfo[1] as any).fileInfo.type.type).toBe(1); // pic (thumb)
});
it('[#145] group video carries real width/height; c2c stays 0/0', async () => {
// A real QQ group video's MsgInfo has real dimensions (e.g. 296x640);
// sending 0x0 makes QQ-NT receivers render 文件已过期 even though the
// resource is fresh (verified on tempserver: 0x0 → expired, real dims →
// renders). c2c is left at 0 — the server rejects non-zero dims there.
await uploadVideoMsgInfo({} as any, true, 12345, FINGERPRINT);
const groupInfo = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploadInfo;
expect((groupInfo[0] as any).fileInfo.width).toBe(320); // FINGERPRINT.width
expect((groupInfo[0] as any).fileInfo.height).toBe(240); // FINGERPRINT.height
vi.mocked(pipeline.runNtv2Upload).mockClear();
await uploadVideoMsgInfo({} as any, false, 'recipient-uid', FINGERPRINT);
const c2cInfo = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploadInfo;
expect((c2cInfo[0] as any).fileInfo.width).toBe(0);
expect((c2cInfo[0] as any).fileInfo.height).toBe(0);
});
it('main video carries the real `time` (duration in seconds) — regression: was 0', async () => {
// NTV2 server bakes the `time` field into the resulting MsgInfo
// bytes that ride along as `commonElem.pbElem`; the receiver
+10 -7
View File
@@ -370,13 +370,16 @@ export async function uploadVideoMsgInfo(
fileSha1: video.sha1Hex,
fileName: 'nya.mp4',
type: { type: 2, picFormat: 0, videoFormat: 0, voiceFormat: 0 },
// Width/height kept at 0 — NapCat does the same and the QQ-NT
// server has been observed to reject non-zero dimensions
// here on c2c sends with a schema-mismatch error. acidify
// *does* fill them (`payload.videoWidth/Height`) but we
// leave that alone until c2c regression coverage exists.
height: 0,
width: 0,
// [#145] Group video MUST carry real width/height. A real QQ
// group video's MsgInfo has them (e.g. 296x640); sending 0x0
// makes QQ-NT receivers (Android especially) fail to lay out
// the video tile and render 文件已过期 even though the resource
// is fresh and downloadable (iOS is lenient — shows expired but
// still opens). c2c is left at 0 because the QQ-NT server has
// been observed to reject non-zero dimensions there with a
// schema-mismatch error (no c2c regression coverage yet).
height: isGroup ? video.height : 0,
width: isGroup ? video.width : 0,
// `time` MUST be the real duration in seconds, otherwise
// every receiving client renders "00:00" on the video.
// NapCat ships `time: 0` because it sits on top of QQ-NT's