feat(onebot): expose group folder upload metadata
Decode the folder modifier metadata returned by group file listings and project it as last upload time, uploader ID, and uploader name for both folder listing actions. Regenerate the MCP catalog and add protocol, bridge, OneBot projection, and action schema coverage for the new fields. Closes #248
This commit is contained in:
10 files changed
+208
-4
No files matched your search
@@ -113,6 +113,9 @@ export const actions = [
|
||||
creator: { type: 'integer', description: '创建者 QQ 号' },
|
||||
create_name: { type: 'string', description: '创建者昵称' },
|
||||
total_file_count: { type: 'integer', description: '文件夹内文件总数' },
|
||||
last_upload_time: { type: 'integer', description: '最后上传时间戳' },
|
||||
last_uploader: { type: 'integer', description: '最后上传者 QQ 号' },
|
||||
last_uploader_name: { type: 'string', description: '最后上传者昵称' },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -165,6 +168,9 @@ export const actions = [
|
||||
creator: { type: 'integer', description: '创建者 QQ 号' },
|
||||
create_name: { type: 'string', description: '创建者昵称' },
|
||||
total_file_count: { type: 'integer', description: '文件夹内文件总数' },
|
||||
last_upload_time: { type: 'integer', description: '最后上传时间戳' },
|
||||
last_uploader: { type: 'integer', description: '最后上传者 QQ 号' },
|
||||
last_uploader_name: { type: 'string', description: '最后上传者昵称' },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -290,4 +296,3 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -210,6 +210,9 @@ export async function getGroupFiles(
|
||||
creator: folder.creator,
|
||||
create_name: folder.creatorName,
|
||||
total_file_count: folder.totalFileCount,
|
||||
last_upload_time: folder.lastUploadTime,
|
||||
last_uploader: folder.lastUploader,
|
||||
last_uploader_name: folder.lastUploaderName,
|
||||
} as JsonObject)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,6 +22,21 @@ describe('action-docs', () => {
|
||||
expect(duration).toMatchObject({ type: 'int', required: false, default: 1800 });
|
||||
});
|
||||
|
||||
it.each(['get_group_root_files', 'get_group_files_by_folder'])(
|
||||
'documents folder last-upload metadata for %s',
|
||||
(name) => {
|
||||
const action = docs.find((d) => d.name === name);
|
||||
const properties = action?.returnsSchema?.properties as Record<string, any> | undefined;
|
||||
const folderProperties = properties?.folders?.items?.properties as Record<string, unknown> | undefined;
|
||||
|
||||
expect(folderProperties).toEqual(expect.objectContaining({
|
||||
last_upload_time: expect.objectContaining({ type: 'integer' }),
|
||||
last_uploader: expect.objectContaining({ type: 'integer' }),
|
||||
last_uploader_name: expect.objectContaining({ type: 'string' }),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
it('renders markdown with header + an action section', () => {
|
||||
const md = renderActionDocsMarkdown(docs);
|
||||
expect(md).toContain('# OneBot Actions');
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
import {
|
||||
getFriendList,
|
||||
getGroupInfo,
|
||||
getGroupFiles,
|
||||
getGroupList,
|
||||
getGroupMemberInfo,
|
||||
getGroupMemberList,
|
||||
@@ -164,6 +165,35 @@ describe('onebot/contact-actions / getFriendList', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('onebot/contact-actions / getGroupFiles', () => {
|
||||
it('returns folder last-upload metadata in OneBot field names', async () => {
|
||||
const list = vi.fn(async () => ({
|
||||
files: [],
|
||||
folders: [{
|
||||
folderId: 'd1',
|
||||
folderName: 'dir',
|
||||
createTime: 100,
|
||||
creator: 123,
|
||||
creatorName: 'creator',
|
||||
totalFileCount: 2,
|
||||
lastUploadTime: 200,
|
||||
lastUploader: 5_000_000_001,
|
||||
lastUploaderName: 'uploader',
|
||||
}],
|
||||
}));
|
||||
const bridge = fakeBridge({ apis: { groupFile: { list } } });
|
||||
|
||||
const out = await getGroupFiles(bridge, 12345, '/');
|
||||
|
||||
expect(out.folders).toEqual([expect.objectContaining({
|
||||
last_upload_time: 200,
|
||||
last_uploader: 5_000_000_001,
|
||||
last_uploader_name: 'uploader',
|
||||
})]);
|
||||
expect(list).toHaveBeenCalledWith(12345, '/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('onebot/contact-actions / getGroupList', () => {
|
||||
it('triggers fetch when the in-memory roster is empty', async () => {
|
||||
const fetched = [makeGroup(100, 'Group A')];
|
||||
|
||||
Reference in new issue
Block a user