fix(protocol): classify private file subcommand receipts

Drop download acknowledgements carried by the offline-file subcommand in both push and history paths, while retaining incoming file transfers.

Fixes #477
This commit is contained in:
DrSmoothl committed 2026-09-26 16:09:31 +08:00
1 parent 805665a6d6
commit 075a27cc46
3 files changed
+42 -8

No files matched your search

@@ -123,6 +123,7 @@ describe('parseMsgPush — empty message drop (#102)', () => {
it('keeps a real incoming c2c file (#442)', () => {
const extra = protobuf_encode<FileExtra>({
file: {
fileType: 1,
fileUuid: 'fid-from-user',
fileName: 'doc.bin',
fileSize: 10n,
@@ -141,6 +142,26 @@ describe('parseMsgPush — empty message drop (#102)', () => {
});
});
it.each(['msgContent', 'richText'] as const)('drops a subcommand receipt in %s without a download flag (#477)', (location) => {
const entries: LogEntry[] = [];
setLogLevel('trace');
const unsubscribe = subscribeLogs((entry) => entries.push(entry));
const file = { fileType: 1, subcmd: 2, fileUuid: 'already-sent', fileName: 'test.json', fileSize: 42n };
try {
const out = parseMsgPush(pushPacket({
responseHead: { fromUin: 10001, fromUid: 'u_x' },
contentHead: { msgType: 529, subType: 4, c2cCmd: 4, sequence: 10, timestamp: 1, msgId: 1 },
body: location === 'msgContent'
? { msgContent: protobuf_encode<FileExtra>({ file }) }
: { richText: { notOnlineFile: file } },
}), identity);
expect(out).toEqual([]);
expect(traceMessages(entries).some((message) => message.includes('branch=offline_file_receipt'))).toBe(true);
} finally {
unsubscribe();
}
});
it('records the precise branch for a C2C control push with content', () => {
// 166 + c2c_cmd ∈ {1,73,75,129,131,133,135,192} is a control/system signal
// QQ NT routes via OnRecvSysMsg, never a bubble — drop regardless of body.