refactor(protocol): keep Decoder a pure parse of MsgPush events
Decoder used to write Identity: decodeGroupAdmin patched member roles and decodeFriendMessage stashed invite-card msgseq. That split observation with IncomingPacketPipeline.rememberEventIdentity and put pending-application state on Identity. Decoder now only returns events. Invite-card groupUin/msgseq ride on FriendMessage; the live pipeline writes them to ContactsApi through an optional port. Role self-heal for #93 stays in rememberEventIdentity. History and forward decode do not write. Identity no longer stores invite-card sequences. Live #93 and #125 behavior is unchanged.
This commit is contained in:
12 files changed
+148
-79
No files matched your search
@@ -133,10 +133,6 @@ export class IdentityService {
|
||||
private readonly userProfiles_ = new Map<number, UserProfileInfo>();
|
||||
private friends_: FriendInfo[] = [];
|
||||
private readonly groups_ = new Map<number, QQGroupInfo>();
|
||||
// groupUin → approval msgseq from a private "qun.invite" card's jumpUrl.
|
||||
// The 0x10c8 approval for a bot self-invite needs THIS sequence (with
|
||||
// eventType=2); the MSF invite push never carries it. See issue #125.
|
||||
private readonly groupInviteCardSeqs_ = new Map<number, number>();
|
||||
|
||||
// ─── Bidirectional UID↔UIN index (O(1), populated by every observation) ───
|
||||
private readonly uinByUid = new Map<string, number>();
|
||||
@@ -615,26 +611,6 @@ export class IdentityService {
|
||||
this.runWrite('user profile', () => this.transaction(() => this.upsertUser(persisted)));
|
||||
}
|
||||
|
||||
/** Remember the approval msgseq carried by a private "qun.invite" card's
|
||||
* jumpUrl, keyed by group. `set_group_add_request` reads it back to approve
|
||||
* a bot self-invite via 0x10c8 (eventType=2). See issue #125. */
|
||||
rememberGroupInviteCardSequence(groupUin: number, sequence: number): void {
|
||||
this.assertOpen('group invite sequence');
|
||||
if (groupUin > 0 && sequence > 0) this.groupInviteCardSeqs_.set(groupUin, sequence);
|
||||
}
|
||||
|
||||
getGroupInviteCardSequence(groupUin: number): number | undefined {
|
||||
return this.groupInviteCardSeqs_.get(groupUin);
|
||||
}
|
||||
|
||||
/** Reverse lookup used for NapCat-compatible numeric request flags. */
|
||||
findGroupInviteCardGroupBySequence(sequence: number): number | undefined {
|
||||
for (const [groupUin, rememberedSequence] of this.groupInviteCardSeqs_) {
|
||||
if (rememberedSequence === sequence) return groupUin;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
rememberGroupRequests(requests: GroupRequestInfo[]): void {
|
||||
this.beginObservation('group requests');
|
||||
const observed = requests.map((request) => ({ ...request }));
|
||||
|
||||
Reference in new issue
Block a user