refactor(identity): consolidate UID resolution behind IdentityService
Pull the cache→DB→network-fetch fallback cascade for UIN→UID translation into a single async `resolveUid` on IdentityService, and drop the duplicated `resolveUserUid` helper that used to live in bridge-oidb. Bridge injects itself as the IdentityFetcher post-construction so the network fallback runs through the same OIDB profile fetch the helper used. Each action module's `resolveUserUid(bridge, uin, groupId?)` call becomes `bridge.resolveUserUid(uin, groupId?)` — same signature on Bridge, but internally it now goes through `identity.resolveUid` so future changes (retry, coalescing, alternative resolvers) only need to land in one place. This is part 1 of the IdentityService deepening (RoadMap item 1). The QQInfo bypass in msg-push-handler and the broader QQInfo absorption land in the follow-up commit.
This commit is contained in:
20 files changed
+157
-75
No files matched your search
@@ -18,7 +18,6 @@ import {
|
||||
} from './proto/action';
|
||||
|
||||
// Delegated modules
|
||||
import { resolveUserUid as resolveUserUid_ } from './bridge-oidb';
|
||||
import {
|
||||
fetchFriendList as fetchFriendList_,
|
||||
fetchGroupList as fetchGroupList_,
|
||||
@@ -176,6 +175,10 @@ export class Bridge {
|
||||
constructor(qqInfo: QQInfo, identity = IdentityService.memory(qqInfo)) {
|
||||
this.qqInfo_ = qqInfo;
|
||||
this.identity = identity;
|
||||
this.identity.setFetcher({
|
||||
fetchProfile: (uin) => this.fetchUserProfile(uin),
|
||||
fetchGroupMemberList: (gid) => this.fetchGroupMemberList(gid),
|
||||
});
|
||||
this.registerDefaultHandlers();
|
||||
}
|
||||
|
||||
@@ -553,7 +556,7 @@ export class Bridge {
|
||||
// --- Delegated: OIDB helpers ---
|
||||
|
||||
async resolveUserUid(uin: number, groupId?: number): Promise<string> {
|
||||
return resolveUserUid_(this, uin, groupId);
|
||||
return this.identity.resolveUid(uin, groupId);
|
||||
}
|
||||
|
||||
// --- Delegated: Contact / info queries ---
|
||||
|
||||
Reference in new issue
Block a user