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:
DrSmoothl committed 2026-07-13 23:01:54 +08:00
1 parent 03aec3b052
commit 4d93c727bb
5 files changed
+40 -2

No files matched your search

+3
View File
@@ -228,6 +228,9 @@ export interface QQEvent {
export interface FriendMessage extends QQEvent {
kind: 'friend_message';
senderUin: number;
/** Stable QQ UID carried by ResponseHead. Kept internally so the identity
* index can preserve the exact C2C peer instead of re-resolving its UIN. */
senderUid?: string;
senderNick: string;
msgSeq: number;
msgId: number;
@@ -38,6 +38,7 @@ export const decodeFriendMessage: MsgPushDecoder = (ctx) => {
time: ctx.head.timestamp,
selfUin: ctx.selfUin,
senderUin: ctx.fromUin,
senderUid: ctx.fromUid,
msgSeq: ctx.head.sequence,
msgId: ctx.head.msgId & 0x7FFFFFFF,
elements,
+10
View File
@@ -369,6 +369,16 @@ export class IncomingPacketPipeline {
private rememberEventIdentity(event: QQEventVariant): void {
switch (event.kind) {
case 'friend_message':
// The message already carries the authoritative UID/UIN pair. Keep it
// at the receive boundary so later C2C operations never have to infer
// a peer UID from a stale message row or a fallible profile lookup.
this.deps.identity.rememberRequestIdentity({
uid: event.senderUid,
uin: event.senderUin,
source: 'friend_message',
});
break;
case 'group_message': {
// [#1] Self-heal a member's cached group card from message traffic. The
// member cache only refreshes via a member-list refetch, which nothing