fix(msg-push): drop blank "[空消息]" pushes in c2c/group history too (#102)
The #102 fix dropped content-less control pushes only in parseMsgPush (live). History fetches (fetchC2cMessageRange / fetchGroupMessageRange) decoded straight into the result, so the same phantom resurfaced as "[空消息]" on backfill. RE of wrapper.linux.node confirms QQ NT filters blanks on BOTH paths — live/roam C2C via c2c_roam_msg_mgr.cc::FilterBlankMsgAndRetryFetch and group roam via group_roam_msg_worker.cc::FilterBlankSeqsMsg. Extracts the blank test into blank-filter.ts (bodyHasDecodableContent + isBlankMessage) and applies it in all three message-producing paths. A message that decoded to 0 elements but whose body carried content is a missing decoder, not a blank — isBlankMessage returns false there so it's kept (live path still warns).
This commit is contained in:
6 files changed
+103
-22
No files matched your search
@@ -41,12 +41,12 @@ describe('fetchC2cMessageRange / SsoGetC2cMsg', () => {
|
||||
{
|
||||
responseHead: { fromUin: 222, forward: { friendName: 'Bob' } },
|
||||
contentHead: { msgType: 166, sequence: 120, timestamp: 1700000120, msgId: 7120 },
|
||||
body: { richText: { elems: [] } },
|
||||
body: { richText: { elems: [{ text: { str: 'hi' } }] } },
|
||||
},
|
||||
{
|
||||
responseHead: { fromUin: 111, forward: { friendName: 'Alice' } },
|
||||
contentHead: { msgType: 166, sequence: 110, timestamp: 1700000110, msgId: 7110 },
|
||||
body: { richText: { elems: [] } },
|
||||
body: { richText: { elems: [{ text: { str: 'hi' } }] } },
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -61,6 +61,27 @@ describe('fetchC2cMessageRange / SsoGetC2cMsg', () => {
|
||||
expect(out[1]).toMatchObject({ msgSeq: 120, senderUin: 222, senderNick: 'Bob' });
|
||||
});
|
||||
|
||||
it('drops content-less blank messages, keeps real ones (#102 parity)', async () => {
|
||||
const resp = protobuf_encode<SsoGetC2cMsgResponse>({
|
||||
friendUid: 'u_friend',
|
||||
messages: [
|
||||
{ // genuinely-blank control push (the invite phantom) → dropped
|
||||
responseHead: { fromUin: 111, forward: { friendName: 'Alice' } },
|
||||
contentHead: { msgType: 166, sequence: 110, timestamp: 1700000110, msgId: 7110 },
|
||||
body: { richText: { elems: [] } },
|
||||
},
|
||||
{ // real message → kept
|
||||
responseHead: { fromUin: 222, forward: { friendName: 'Bob' } },
|
||||
contentHead: { msgType: 166, sequence: 120, timestamp: 1700000120, msgId: 7120 },
|
||||
body: { richText: { elems: [{ text: { str: 'hi' } }] } },
|
||||
},
|
||||
],
|
||||
});
|
||||
const out = await fetchC2cMessageRange({ sendRawPacket: async () => okResult(resp) }, identity, 10001, 'u_friend', 100, 120);
|
||||
expect(out.map((m) => m.msgSeq)).toEqual([120]);
|
||||
expect(out[0]).toMatchObject({ senderUin: 222, elements: [{ type: 'text', text: 'hi' }] });
|
||||
});
|
||||
|
||||
it('returns [] on a failed packet, empty uid, or out-of-range request', async () => {
|
||||
const failSender = { sendRawPacket: async () => ({ success: false, gotResponse: false } as SendPacketResult) };
|
||||
expect(await fetchC2cMessageRange(failSender, identity, 10001, 'u_x', 100, 120)).toEqual([]);
|
||||
|
||||
@@ -45,12 +45,12 @@ describe('fetchGroupMessageRange / SsoGetGroupMsg', () => {
|
||||
{
|
||||
responseHead: { fromUin: 222, grp: { groupUin: 9999, memberName: 'Bob' } },
|
||||
contentHead: { msgType: 82, sequence: 120, timestamp: 1700000120, msgId: 5120 },
|
||||
body: { richText: { elems: [] } },
|
||||
body: { richText: { elems: [{ text: { str: 'hi' } }] } },
|
||||
},
|
||||
{
|
||||
responseHead: { fromUin: 111, grp: { groupUin: 9999, memberName: 'Alice' } },
|
||||
contentHead: { msgType: 82, sequence: 110, timestamp: 1700000110, msgId: 5110 },
|
||||
body: { richText: { elems: [] } },
|
||||
body: { richText: { elems: [{ text: { str: 'hi' } }] } },
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -67,6 +67,29 @@ describe('fetchGroupMessageRange / SsoGetGroupMsg', () => {
|
||||
expect(out[1]).toMatchObject({ msgSeq: 120, senderUin: 222, senderNick: 'Bob' });
|
||||
});
|
||||
|
||||
it('drops content-less blank messages, keeps real ones (#102 parity)', async () => {
|
||||
const resp = protobuf_encode<SsoGetGroupMsgResponse>({
|
||||
body: {
|
||||
groupUin: 9999,
|
||||
messages: [
|
||||
{ // genuinely-blank control push → dropped
|
||||
responseHead: { fromUin: 111, grp: { groupUin: 9999, memberName: 'Alice' } },
|
||||
contentHead: { msgType: 82, sequence: 110, timestamp: 1700000110, msgId: 5110 },
|
||||
body: { richText: { elems: [] } },
|
||||
},
|
||||
{ // real message → kept
|
||||
responseHead: { fromUin: 222, grp: { groupUin: 9999, memberName: 'Bob' } },
|
||||
contentHead: { msgType: 82, sequence: 120, timestamp: 1700000120, msgId: 5120 },
|
||||
body: { richText: { elems: [{ text: { str: 'hi' } }] } },
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const out = await fetchGroupMessageRange({ sendRawPacket: async () => okResult(resp) }, identity, 10001, 9999, 100, 120);
|
||||
expect(out.map((m) => m.msgSeq)).toEqual([120]);
|
||||
expect(out[0]).toMatchObject({ senderUin: 222, elements: [{ type: 'text', text: 'hi' }] });
|
||||
});
|
||||
|
||||
it('returns [] on a failed packet or out-of-range request', async () => {
|
||||
const failSender = { sendRawPacket: async () => ({ success: false, gotResponse: false } as SendPacketResult) };
|
||||
expect(await fetchGroupMessageRange(failSender, identity, 10001, 9999, 100, 120)).toEqual([]);
|
||||
|
||||
Reference in new issue
Block a user