feat(onebot): implement rename_group_file (OIDB 0x6D6_4)
Add the file-rename slot to the group-file OIDB envelope (req/resp field 5), a RenameGroupFile service mirroring MoveGroupFile, a groupFile.rename() api method, and the rename_group_file action (params group_id/file_id/ current_parent_directory/new_name, NapCat-aligned), replacing the stub. Wire fields (busId=102, parentFolder=current dir, newFileName) verified against NapCat's Oidb.0x6D6 transformer; subCommand 4 cross-checked against the move op (sub 5 on both sides). Serialize + envelope round-trip test locks the pb tags.
This commit is contained in:
8 files changed
+178
-9
No files matched your search
@@ -683,3 +683,34 @@ describe('extended-actions / get_file', () => {
|
||||
expect(res).toMatchObject({ status: 'failed', retcode: 1400 });
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Wave 2: rename_group_file (0x6D6_4) ───
|
||||
|
||||
describe('extended-actions / rename_group_file', () => {
|
||||
it('renames a group file via apis.groupFile.rename', async () => {
|
||||
const rename = vi.fn(async () => undefined);
|
||||
const bridge = fakeBridge({ apis: { groupFile: { rename } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('rename_group_file', {
|
||||
group_id: 12345, file_id: '/abc', current_parent_directory: '/', new_name: 'new.txt',
|
||||
});
|
||||
expect(res.status).toBe('ok');
|
||||
expect(rename).toHaveBeenCalledWith(12345, '/abc', '/', 'new.txt');
|
||||
});
|
||||
|
||||
it('rejects missing required params', async () => {
|
||||
const rename = vi.fn();
|
||||
const bridge = fakeBridge({ apis: { groupFile: { rename } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('rename_group_file', { group_id: 12345, file_id: '/abc' });
|
||||
expect(res).toMatchObject({ status: 'failed', retcode: 1400 });
|
||||
expect(rename).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('surfaces oidb errors (handler maps a thrown error to INTERNAL_ERROR, as its sibling file ops do)', async () => {
|
||||
const rename = vi.fn(async () => { throw new Error('rename rejected'); });
|
||||
const bridge = fakeBridge({ apis: { groupFile: { rename } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('rename_group_file', {
|
||||
group_id: 1, file_id: '/a', current_parent_directory: '/', new_name: 'x',
|
||||
});
|
||||
expect(res).toMatchObject({ status: 'failed', retcode: 1200, wording: 'rename rejected' });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user