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)),
|
||||
}));
|
||||
|
||||
@@ -30,7 +29,6 @@ describe('actions/group-file', () => {
|
||||
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();
|
||||
});
|
||||
@@ -104,7 +102,7 @@ describe('actions/group-file', () => {
|
||||
const bridge = mockBridge({
|
||||
qqInfo: { uin: '10001', selfUid: '', findGroupMember: vi.fn(() => null) },
|
||||
});
|
||||
vi.mocked(oidb.resolveUserUid)
|
||||
vi.mocked(bridge.resolveUserUid)
|
||||
.mockResolvedValueOnce('target-uid') // target user
|
||||
.mockResolvedValueOnce('self-uid-resolved'); // self fallback
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
@@ -112,7 +110,7 @@ describe('actions/group-file', () => {
|
||||
});
|
||||
const out = await groupFile.uploadPrivateFile(bridge as any, 67890, '/path/file');
|
||||
expect(out).toEqual({ fileId: 'fid', fileHash: 'hash' });
|
||||
expect(oidb.resolveUserUid).toHaveBeenCalledTimes(2);
|
||||
expect(bridge.resolveUserUid).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('fetchGroupFiles paginates files + folders out of OIDB items', async () => {
|
||||
|
||||
Reference in new issue
Block a user