feat(core,onebot): implement trans_group_file action (#161)
This commit is contained in:
1 parent
2f374ea8c9
commit
9ca64bed10
11 files changed
+260
-10
No files matched your search
@@ -65,6 +65,7 @@ export interface MockGroupFileApi {
|
||||
upload: ReturnType<typeof vi.fn>;
|
||||
uploadPrivate: ReturnType<typeof vi.fn>;
|
||||
publish: ReturnType<typeof vi.fn>;
|
||||
trans: ReturnType<typeof vi.fn>;
|
||||
getCount: ReturnType<typeof vi.fn>;
|
||||
list: ReturnType<typeof vi.fn>;
|
||||
getUrl: ReturnType<typeof vi.fn>;
|
||||
@@ -85,6 +86,7 @@ export function mockGroupFileApi(): MockGroupFileApi {
|
||||
upload: vi.fn(async () => ({ fileId: 'stub-fid' })),
|
||||
uploadPrivate: vi.fn(async () => ({ fileId: 'stub-pfid', fileHash: 'stub-hash' })),
|
||||
publish: vi.fn(async () => undefined),
|
||||
trans: vi.fn(async () => ({ saveBusId: 102, saveFilePath: '/stub-path' })),
|
||||
getCount: vi.fn(async () => ({ fileCount: 0, maxCount: 10000 })),
|
||||
list: vi.fn(async () => ({ files: [], folders: [] })),
|
||||
getUrl: vi.fn(async () => 'stub://url'),
|
||||
|
||||
@@ -8,6 +8,7 @@ import type {
|
||||
OidbGroupFileViewResp,
|
||||
OidbGroupFileFolderResp,
|
||||
OidbGroupSendFileReq,
|
||||
OidbGroupSendFileResp,
|
||||
} from '@snowluma/proto-defs/oidb-actions/group-file';
|
||||
import type {
|
||||
OidbPrivateFileUploadResp,
|
||||
@@ -246,6 +247,26 @@ describe('apis/group-file', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('trans hits OIDB 0x6d9_0 and returns the saved path metadata', async () => {
|
||||
const bridge = mockBridge();
|
||||
bridge.sendRawPacket.mockResolvedValueOnce(packResponse(
|
||||
protobuf_encode<OidbBase<OidbGroupSendFileResp>>({
|
||||
body: { transFile: { saveBusId: 102, saveFilePath: '/saved/path' } },
|
||||
}),
|
||||
));
|
||||
const out = await new GroupFileApi(bridge as any).trans(12345, 'fid-trans');
|
||||
expect(out).toEqual({ saveBusId: 102, saveFilePath: '/saved/path' });
|
||||
const [wire, bytes] = bridge.sendRawPacket.mock.calls[0]!;
|
||||
expect(wire).toBe('OidbSvcTrpcTcp.0x6d9_0');
|
||||
const env = protobuf_decode<OidbBase<OidbGroupSendFileReq>>(bytes);
|
||||
expect(env.body?.transFile).toMatchObject({
|
||||
groupUin: 12345n,
|
||||
appId: 7,
|
||||
busId: 102,
|
||||
fileId: 'fid-trans',
|
||||
});
|
||||
});
|
||||
|
||||
it('uploadPrivate resolves both target + self UID before OIDB call', async () => {
|
||||
const bridge = mockBridge({
|
||||
identity: {
|
||||
|
||||
Reference in new issue
Block a user