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.*`.
This commit is contained in:
27 files changed
+363
-428
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import type { WebHonorType } from '@/bridge/web/group-honor';
|
||||
import type { Bridge } from '../bridge/bridge';
|
||||
import type { QQInfo } from '../bridge/qq-info';
|
||||
import type { ApiActionContext } from './api-handler';
|
||||
import type { ConverterContext } from './event-converter';
|
||||
import type { MediaStore } from './media-store';
|
||||
@@ -56,7 +55,6 @@ export interface OneBotInstanceContext {
|
||||
/** Self UIN parsed once, used in event payloads. */
|
||||
selfId: number;
|
||||
|
||||
qqInfo: QQInfo;
|
||||
bridge: Bridge;
|
||||
|
||||
messageStore: MessageStore;
|
||||
@@ -74,7 +72,7 @@ export interface OneBotInstanceContext {
|
||||
}
|
||||
|
||||
export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
|
||||
const { bridge, qqInfo, messageStore, mediaStore } = ref;
|
||||
const { bridge, messageStore, mediaStore } = ref;
|
||||
|
||||
return {
|
||||
getLoginInfo: () => getLoginInfo(ref),
|
||||
@@ -90,12 +88,12 @@ export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
|
||||
deleteMessage: (_messageId, meta) => deleteMessage(bridge, meta),
|
||||
|
||||
// OneBot11 info actions.
|
||||
getFriendList: () => getFriendList(bridge, qqInfo),
|
||||
getGroupList: (noCache) => getGroupList(bridge, qqInfo, noCache),
|
||||
getGroupInfo: (groupId, noCache) => getGroupInfo(bridge, qqInfo, groupId, noCache),
|
||||
getGroupMemberList: (groupId, noCache) => getGroupMemberList(bridge, qqInfo, groupId, noCache),
|
||||
getGroupMemberInfo: (groupId, userId, noCache) => getGroupMemberInfo(bridge, qqInfo, groupId, userId, noCache),
|
||||
getStrangerInfo: (userId) => getStrangerInfo(bridge, qqInfo, userId),
|
||||
getFriendList: () => getFriendList(bridge),
|
||||
getGroupList: (noCache) => getGroupList(bridge, noCache),
|
||||
getGroupInfo: (groupId, noCache) => getGroupInfo(bridge, groupId, noCache),
|
||||
getGroupMemberList: (groupId, noCache) => getGroupMemberList(bridge, groupId, noCache),
|
||||
getGroupMemberInfo: (groupId, userId, noCache) => getGroupMemberInfo(bridge, groupId, userId, noCache),
|
||||
getStrangerInfo: (userId) => getStrangerInfo(bridge, userId),
|
||||
|
||||
// Group admin.
|
||||
setGroupKick: (groupId, userId, reject) => bridge.kickGroupMember(groupId, userId, reject),
|
||||
|
||||
Reference in new issue
Block a user