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
@@ -3,7 +3,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
resolveUserUid: vi.fn(async () => 'resolved-uid'),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
}));
|
||||
|
||||
@@ -27,7 +26,6 @@ describe('actions/profile', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndCheck).mockClear();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockClear();
|
||||
vi.mocked(oidb.resolveUserUid).mockClear();
|
||||
vi.mocked(highwayClient.fetchHighwaySession).mockClear();
|
||||
vi.mocked(highwayClient.uploadHighwayHttp).mockClear();
|
||||
});
|
||||
@@ -63,7 +61,7 @@ describe('actions/profile', () => {
|
||||
it('setInputStatus resolves UID first and sends 0xcd4_1', async () => {
|
||||
const bridge = mockBridge();
|
||||
await profile.setInputStatus(bridge as any, 10001, 1);
|
||||
expect(oidb.resolveUserUid).toHaveBeenCalledWith(bridge, 10001);
|
||||
expect(bridge.resolveUserUid).toHaveBeenCalledWith(10001);
|
||||
const call = vi.mocked(oidb.sendOidbAndDecode).mock.calls[0]!;
|
||||
expect(call[1]).toBe('OidbSvcTrpcTcp.0xcd4_1');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user