fix(video): fall back to portrait dims on fast-upload group video

The width/height=0 → 文件已过期 fix only covered the normal upload path, which
ffprobes real dimensions. The fast-upload (fingerprint / forward) path has no
bytes to probe and takes dimensions from cached metadata, which is 0 when the
source video arrived on the wire without dimensions (e.g. forwarded from another
client that itself sent 0x0). Re-forwarding such a video to a group then shipped
0x0 and the receiver rendered a stale "expired" placeholder.

videoPayloadFromFingerprint now substitutes a neutral 720x1280 portrait when a
dimension is absent or zero (|| not ??, so a cached 0 is replaced too). Real
cached dimensions always win; c2c is unaffected (the wire builder forces 0 there
regardless). A forwarded dimensionless video now renders and plays instead of
showing 文件已过期; verified on-target by forwarding a zeroed-dim video.
This commit is contained in:
DrSmoothl committed 2026-07-05 15:39:35 +08:00
1 parent 0e6e2ec51d
commit ac20956076
2 files changed
+32 -2

No files matched your search

@@ -123,6 +123,23 @@ describe('video-upload', () => {
expect((c2cInfo[0] as any).fileInfo.height).toBe(0);
});
it('[#145] fast-upload with 0x0 dims (e.g. forwarding a dimensionless video) falls back to portrait for group', async () => {
// A forwarded video whose cached dims are 0 must NOT ship 0x0 to a group
// (→ 文件已过期). videoPayloadFromFingerprint substitutes a neutral 720x1280
// portrait; c2c stays 0 (server rejects non-zero there).
const noDims = { ...FINGERPRINT, width: 0, height: 0 } as any;
await uploadVideoMsgInfo({} as any, true, 12345, noDims);
const groupInfo = vi.mocked(pipeline.runNtv2Upload).mock.calls[0]![0].uploadInfo;
expect((groupInfo[0] as any).fileInfo.width).toBe(720);
expect((groupInfo[0] as any).fileInfo.height).toBe(1280);
vi.mocked(pipeline.runNtv2Upload).mockClear();
await uploadVideoMsgInfo({} as any, false, 'recipient-uid', noDims);
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