diff --git a/packages/core/tests/highway/video-upload.test.ts b/packages/core/tests/highway/video-upload.test.ts index cd1eb8ec..3894eca4 100644 --- a/packages/core/tests/highway/video-upload.test.ts +++ b/packages/core/tests/highway/video-upload.test.ts @@ -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 diff --git a/packages/protocol/src/highway/video-upload.ts b/packages/protocol/src/highway/video-upload.ts index 0a285152..bd7546d2 100644 --- a/packages/protocol/src/highway/video-upload.ts +++ b/packages/protocol/src/highway/video-upload.ts @@ -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