fix(protocol): retain C2C peer identities
Carry the stable sender identity through decoded private-message events and persist the UID/UIN pair at the receive boundary. This keeps later conversation operations independent of stale message rows or fallible profile lookups, with regression coverage for decoding and identity indexing.
This commit is contained in:
5 files changed
+40
-2
No files matched your search
@@ -43,7 +43,9 @@ describe('parseMsgPush — empty message drop (#102)', () => {
|
||||
body: { richText: { elems: [{ text: { str: 'hi' } }] } },
|
||||
}), identity);
|
||||
expect(out).toHaveLength(1);
|
||||
expect(out[0]).toMatchObject({ kind: 'friend_message', elements: [{ type: 'text', text: 'hi' }] });
|
||||
expect(out[0]).toMatchObject({
|
||||
kind: 'friend_message', senderUid: 'u_x', elements: [{ type: 'text', text: 'hi' }],
|
||||
});
|
||||
});
|
||||
|
||||
it('drops a C2C control push by (msgType, c2cCmd) even when it carries content', () => {
|
||||
|
||||
@@ -39,7 +39,7 @@ function makePipeline(opts: {
|
||||
events.onAny((event) => { captured.push(event as QQEventVariant); });
|
||||
|
||||
return {
|
||||
pipeline, events, captured,
|
||||
identity, pipeline, events, captured,
|
||||
resolveStrangerProfile, resolveGroupJoinRequest, resolveGroupInviteCardSequence,
|
||||
};
|
||||
}
|
||||
@@ -367,6 +367,28 @@ describe('IncomingPacketPipeline / stranger resolve on group_invite', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('IncomingPacketPipeline / friend message identity', () => {
|
||||
it('preserves the exact UID/UIN pair carried by an incoming C2C message', () => {
|
||||
const { identity, pipeline } = makePipeline();
|
||||
pipeline.registerCmd('test.cmd', () => [{
|
||||
kind: 'friend_message',
|
||||
time: 1700000000,
|
||||
selfUin: 10001,
|
||||
senderUin: 22222,
|
||||
senderUid: 'u_peer_exact',
|
||||
senderNick: 'peer',
|
||||
msgSeq: 1,
|
||||
msgId: 2,
|
||||
elements: [{ type: 'text', text: 'hi' }],
|
||||
}]);
|
||||
|
||||
pipeline.process({ serviceCmd: 'test.cmd' } as PacketInfo);
|
||||
|
||||
expect(identity.findUidByUin(22222)).toBe('u_peer_exact');
|
||||
expect(identity.findUinByUid('u_peer_exact')).toBe(22222);
|
||||
});
|
||||
});
|
||||
|
||||
describe('IncomingPacketPipeline / #1 group card self-heal', () => {
|
||||
function makeGroupMsgPipeline() {
|
||||
const identity = IdentityService.memory('10001');
|
||||
|
||||
Reference in new issue
Block a user