fix(protocol): restore forward image media and drop file receipts
Bot-built merged forwards left hollow NT images after long-msg fetch, so get_forward_msg returned empty file/url. Decode now rebuilds identity from md5, ignores stubs, and forward uploads keep a legacy image sibling. C2C offline-file download receipts were reported as the peer sending a file. Treat downloadFlag=2 as a receipt and drop it from the chat stream.
This commit is contained in:
10 files changed
+340
-24
No files matched your search
@@ -13,7 +13,7 @@ import {
|
||||
} from '@snowluma/common/logger';
|
||||
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { PushMsg, PushMsgBody } from '@snowluma/proto-defs/message';
|
||||
import type { FileExtra, PushMsg, PushMsgBody } from '@snowluma/proto-defs/message';
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import type { IdentityService } from '../../src/identity-service';
|
||||
import { parseMsgPush } from '../../src/msg-push';
|
||||
@@ -101,6 +101,46 @@ describe('parseMsgPush — empty message drop (#102)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('drops an offline-file download receipt instead of a friend file message (#442)', () => {
|
||||
const extra = protobuf_encode<FileExtra>({
|
||||
file: {
|
||||
fileUuid: 'fid-sent-by-bot',
|
||||
fileName: 'doc.bin',
|
||||
fileSize: 6119608n,
|
||||
subcmd: 1,
|
||||
downloadFlag: 2,
|
||||
fileHash: 'abc',
|
||||
},
|
||||
});
|
||||
const out = parseMsgPush(pushPacket({
|
||||
responseHead: { fromUin: 10001, fromUid: 'u_x' },
|
||||
contentHead: { msgType: 529, subType: 0, sequence: 1, timestamp: 1, msgId: 1 },
|
||||
body: { msgContent: extra },
|
||||
}), identity);
|
||||
expect(out).toEqual([]);
|
||||
});
|
||||
|
||||
it('keeps a real incoming c2c file (#442)', () => {
|
||||
const extra = protobuf_encode<FileExtra>({
|
||||
file: {
|
||||
fileUuid: 'fid-from-user',
|
||||
fileName: 'doc.bin',
|
||||
fileSize: 10n,
|
||||
subcmd: 1,
|
||||
},
|
||||
});
|
||||
const out = parseMsgPush(pushPacket({
|
||||
responseHead: { fromUin: 10001, fromUid: 'u_x' },
|
||||
contentHead: { msgType: 529, subType: 0, sequence: 2, timestamp: 1, msgId: 2 },
|
||||
body: { msgContent: extra },
|
||||
}), identity);
|
||||
expect(out).toHaveLength(1);
|
||||
expect(out[0]).toMatchObject({
|
||||
kind: 'friend_message',
|
||||
elements: [{ type: 'file', fileId: 'fid-from-user', fileName: 'doc.bin' }],
|
||||
});
|
||||
});
|
||||
|
||||
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