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
@@ -114,19 +114,10 @@ export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
|
||||
// Group admin — actions now call `ctx.bridge.apis.groupAdmin.X(...)`
|
||||
// directly; no per-method passthrough here anymore.
|
||||
|
||||
// Group file — fileId field extraction + defaults.
|
||||
uploadGroupFile: async (groupId, file, name, folderId, uploadFile) => {
|
||||
const result = await bridge.apis.groupFile.upload(groupId, file, name ?? '', folderId ?? '/', uploadFile ?? true);
|
||||
return result.fileId;
|
||||
},
|
||||
uploadPrivateFile: async (userId, file, name, uploadFile) => {
|
||||
const result = await bridge.apis.groupFile.uploadPrivate(userId, file, name ?? '', uploadFile ?? true);
|
||||
return result.fileId;
|
||||
},
|
||||
getGroupFileUrl: (groupId, fileId, busId) => bridge.apis.groupFile.getUrl(groupId, fileId, busId ?? 102),
|
||||
// Group file — `getGroupFiles` stays because the module helper
|
||||
// enriches uploader/creator names from the identity cache; the
|
||||
// rest of the area is called directly via `ctx.bridge.apis.groupFile.*`.
|
||||
getGroupFiles: (groupId, folderId) => getGroupFiles(bridge, groupId, folderId),
|
||||
createGroupFileFolder: (groupId, name, parentId) => bridge.apis.groupFile.createFolder(groupId, name, parentId ?? '/'),
|
||||
getPrivateFileUrl: (userId, fileId, fileHash) => bridge.apis.groupFile.getPrivateUrl(userId, fileId, fileHash),
|
||||
|
||||
// Requests — name translation.
|
||||
handleFriendRequest: (flag, approve) => bridge.apis.friend.handleRequest(flag, approve),
|
||||
@@ -161,7 +152,6 @@ export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
|
||||
forceFetchClientKey: () => bridge.apis.web.forceFetchClientKey(),
|
||||
setFriendRemark: (userId, remark) => bridge.apis.friend.setRemark(userId, remark),
|
||||
setGroupAvatar: (groupId, source) => bridge.apis.profile.setGroupAvatar(groupId, source),
|
||||
getGroupFileCount: (groupId) => bridge.apis.groupFile.getCount(groupId),
|
||||
|
||||
// Cross-store: looks up the meta then routes through Bridge.
|
||||
setMsgEmojiLike: async (messageId, emojiId, set) => {
|
||||
|
||||
Reference in new issue
Block a user