refactor(protocol): compose group-file URLs in the OIDB namespaces

Move retCode checks and URL assembly into GetGroupFileUrl,
GetPrivateFileUrl, and ListGroupFilesPage so GroupFileApi only
loops pages and resolves display names.
This commit is contained in:
DrSmoothl committed 2026-08-16 21:56:21 +08:00
1 parent 3fc521fb8b
commit 55a2a24fc2
9 files changed
+104 -82

No files matched your search

@@ -43,14 +43,12 @@ describe('GetPrivateFileUrl namespace', () => {
expect(env.body?.field99999).toEqual(new Uint8Array([0xC0, 0x85, 0x2C, 0x01]));
});
it('returns the result sub-message verbatim', async () => {
it('composes the http download URL', async () => {
const deps = makeDeps({
body: { result: { server: 'srv', port: 8080, url: '/path' } } as any,
});
const out = await GetPrivateFileUrl.invoke(deps, { selfUid: 's', fileId: 'f', fileHash: 'h' });
expect(out.server).toBe('srv');
expect(out.port).toBe(8080);
expect(out.url).toBe('/path');
await expect(GetPrivateFileUrl.invoke(deps, { selfUid: 's', fileId: 'f', fileHash: 'h' }))
.resolves.toBe('http://srv:8080/path&isthumb=0');
});
it('throws when result is missing', async () => {
@@ -58,4 +56,12 @@ describe('GetPrivateFileUrl namespace', () => {
await expect(GetPrivateFileUrl.invoke(deps, { selfUid: 's', fileId: 'f', fileHash: 'h' }))
.rejects.toThrow(/private file url response invalid/);
});
it('throws when server/port/url is incomplete', async () => {
const deps = makeDeps({
body: { result: { server: 'srv', port: 0, url: '/path' } } as any,
});
await expect(GetPrivateFileUrl.invoke(deps, { selfUid: 's', fileId: 'f', fileHash: 'h' }))
.rejects.toThrow(/private file url response invalid/);
});
});