refactor(onebot): inline ctx.bridge.apis.groupFile direct calls
Remove 6 passthrough fields from ApiActionContext for the group-file area (`uploadGroupFile / uploadPrivateFile / getGroupFileUrl / createGroupFileFolder / getPrivateFileUrl / getGroupFileCount`). Action sites (`actions/group-file.ts` and one site in `actions/extended.ts`) now call `ctx.bridge.apis.groupFile.<method>` directly. `getGroupFiles` stays on the ctx because its module helper (`getGroupFiles(bridge, groupId, folderId)` in `modules/contact-actions.ts`) does identity-lookup enrichment of uploader/creator names — not a pure passthrough. Behavior preserved: same default values (`name = ''`, `folderId = '/'`, `busId = 102`, `uploadFile = true`) — they were baked into the ctx wrapper before, now they're explicit in the action site (`asString` returns `''`, `... || '/'`, `... || 102`, `asBoolean(..., true)`). The result-unwrap (`fileId` extraction from `UploadFileResult`) moves from the ctx wrapper into the action handler. Part 2 of the OneBot-side slim-down. 552/552 tests still green.
This commit is contained in:
4 files changed
+18
-38
No files matched your search
@@ -573,18 +573,10 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
h.registerAction('get_group_file_system_info', async (params) => {
|
||||
const groupId = asNumber(params.group_id);
|
||||
if (!groupId) return failedResponse(RETCODE.BAD_REQUEST, 'group_id is required');
|
||||
if (ctx.getGroupFileCount) {
|
||||
const info = await ctx.getGroupFileCount(groupId);
|
||||
return okResponse({
|
||||
file_count: info.fileCount,
|
||||
limit_count: info.maxCount,
|
||||
used_space: 0,
|
||||
total_space: 10737418240,
|
||||
});
|
||||
}
|
||||
const info = await ctx.bridge.apis.groupFile.getCount(groupId);
|
||||
return okResponse({
|
||||
file_count: 0,
|
||||
limit_count: 10000,
|
||||
file_count: info.fileCount,
|
||||
limit_count: info.maxCount,
|
||||
used_space: 0,
|
||||
total_space: 10737418240,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user