Files
SnowLuma/packages/core/src/bridge/qq-info.ts
T
DrSmoothl ac10c663f1 refactor(identity): absorb QQInfo into IdentityService
QQInfo's in-memory state (self identity, friends, group rosters,
profile cache) and read methods (findFriend / findGroup /
findGroupMember / findUserProfile / nickname / uin / selfProfile) now
live directly on IdentityService. The QQInfo class is gone; its
interfaces stay in `qq-info.ts` as plain types shared across the
remember*/find* surface.

This eliminates a long-standing duplication: every observation used to
maintain both QQInfo's in-memory structures and IdentityService's
SQLite mirror in parallel, with the uidByUin/uinByUid Maps tracked
separately. With one Module owning all three layers, every remember*
hydrates one set of structures and `loadSnapshot` repopulates the
in-memory uid↔uin index from SQLite on startup — closing the cold-cache
gap that previously forced findUidByUin to fall through to a SQLite
query after every restart.

Knock-on changes:
  - `Bridge` no longer holds a QQInfo; constructor takes an
    `IdentityService`. The CmdParser signature on the cmd dispatch
    table now passes `IdentityService` to parsers.
  - `msg-push-handler.ts` drops its private `resolveUidToUin(qqInfo, …)`
    helper that bypassed IdentityService's cascade — the parser hot
    path now reads through `identity.findUinByUid(uid, groupId)` and
    benefits from the O(1) `uinByUid` map even on freshly-loaded
    sessions.
  - `BridgeManager`'s session-started callback drops the QQInfo
    parameter; OneBotInstance no longer carries a `qqInfo` field and
    exposes a `nickname` getter for the WebUI listing.
  - `contact-actions` and the per-theme bridge action files stop
    importing QQInfo; they read everything via `bridge.identity.*`.
2026-05-15 00:44:01 +08:00

65 lines
1.3 KiB
TypeScript

// Domain object shapes shared by IdentityService and its callers. The
// concrete state (own UIN, friends list, group rosters, profile cache)
// lives inside IdentityService — these interfaces just describe the
// records that flow across remember*/refresh* and find* boundaries.
export interface UserProfileInfo {
uin: number;
uid: string;
nickname: string;
remark: string;
qid: string;
sex: string;
age: number;
sign: string;
avatar: string;
}
export interface FriendInfo {
uin: number;
uid: string;
nickname: string;
remark: string;
}
export interface GroupMemberInfo {
uin: number;
uid: string;
nickname: string;
card: string;
role: string; // 'owner' | 'admin' | 'member'
level: number;
title: string;
joinTime: number;
lastSentTime: number;
shutUpTime: number;
}
export interface QQGroupInfo {
groupId: number;
groupName: string;
remark: string;
memberCount: number;
memberMax: number;
members: Map<number, GroupMemberInfo>;
}
export interface GroupRequestInfo {
groupId: number;
groupName: string;
targetUid: string;
targetUin: number;
targetName: string;
invitorUid: string;
invitorUin: number;
invitorName: string;
operatorUid: string;
operatorUin: number;
operatorName: string;
sequence: number;
state: number;
eventType: number;
comment: string;
filtered: boolean;
}