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:
3 files changed
+42
-8
No files matched your search
@@ -51,4 +51,17 @@ describe('classifyMessageSurvival', () => {
|
||||
};
|
||||
expect(classifyMessageSurvival(privateHead, [{ type: 'file' }], body)).toBe('drop-receipt');
|
||||
});
|
||||
|
||||
it('classifies subcommand receipts consistently for history and push consumers (#477)', () => {
|
||||
const file = { fileType: 1, subcmd: 2, fileUuid: 'already-sent', fileName: 'test.json', fileSize: 42n };
|
||||
for (const body of [
|
||||
{ msgContent: protobuf_encode<FileExtra>({ file }) },
|
||||
{ richText: { notOnlineFile: file } },
|
||||
]) {
|
||||
expect(classifyMessageSurvival(privateHead, [{ type: 'file' }], body)).toBe('drop-receipt');
|
||||
}
|
||||
expect(classifyMessageSurvival(privateHead, [{ type: 'file' }], {
|
||||
richText: { notOnlineFile: { ...file, fileType: 3 } },
|
||||
})).toBe('keep');
|
||||
});
|
||||
});
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user