refactor(api): move 17 group-file methods to GroupFileApi (#6 commit 4/13)
Inlines `actions/group-file.ts` into `apis/group-file.ts::GroupFileApi`,
deletes the old action file, removes the matching 17 facade methods
off `Bridge`, and slims `BridgeInterface` accordingly.
Method renaming follows the same "strip the redundant suffix" rule we
applied to GroupAdminApi:
uploadGroupFile → upload
uploadPrivateFile → uploadPrivate
sendGroupFileMessage → publish (OIDB 0x6d9_4)
fetchGroupFiles → list
fetchGroupFileCount → getCount
fetchGroupFileUrl → getUrl
fetchPrivateFileUrl → getPrivateUrl
fetchGroupPttUrlByNode → getPttUrl
fetchPrivatePttUrlByNode → getPrivatePttUrl
fetchGroupVideoUrlByNode → getVideoUrl
fetchPrivateVideoUrlByNode → getPrivateVideoUrl
deleteGroupFile → delete
moveGroupFile → move
createGroupFileFolder → createFolder
deleteGroupFileFolder → deleteFolder
renameGroupFileFolder → renameFolder
`upload`'s atomic upload+publish flow now calls `this.publish(...)`
directly instead of going through `bridge.sendGroupFileMessage`, and
`uploadPrivate` calls `this.ctx.apis.message.sendC2cFile(...)`.
Callers updated: `instance-context.ts`, `media-url-resolver.ts`,
`actions/group-file.ts` (onebot), `actions/extended.ts`,
`modules/{contact,media,message}-actions.ts`.
Tests: `group-file.test.ts` rewritten to use
`new GroupFileApi(bridge as any).method(...)`. The "verify publish was
called" assertions now use `vi.spyOn(api, 'publish').mockResolvedValue()`
since `publish` is an instance method on the same Api. `_helpers.ts`
gains `mockGroupFileApi()` for cross-Api callers and drops the flat
`sendGroupFileMessage` shim. `media-url-resolver.test.ts` and
`send-group-file.test.ts` switched to `bridge.apis.groupFile.*`; the
extended-actions `APIS_ROUTING` map now carries a `[area, newName]`
tuple so renamed methods auto-promote.
587/587 tests pass. The network-manager file remains as the only
failing test file (pre-existing infrastructure issue unrelated to #6).
This commit is contained in:
1 parent
0b91e4db8d
commit
dad501ebc0
17 files changed
+1241
-1185
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import type { SendPacketResult } from '../protocol/packet-sender';
|
||||
import type { ApiHub } from './apis';
|
||||
import type { GroupFilesResult } from './actions/group-file';
|
||||
import type { MediaIndexNode } from './actions/shared';
|
||||
import type {
|
||||
ClientKeyInfo,
|
||||
@@ -53,32 +52,15 @@ export interface BridgeInterface {
|
||||
deleteFriend(userId: number, block?: boolean): Promise<void>;
|
||||
setFriendRemark(userId: number, remark: string): Promise<void>;
|
||||
|
||||
// ─── Files ───
|
||||
uploadGroupFile(groupId: number, file: string, name?: string, folderId?: string, uploadFile?: boolean): Promise<{ fileId: string | null }>;
|
||||
uploadPrivateFile(userId: number, file: string, name?: string, uploadFile?: boolean): Promise<{ fileId: string | null }>;
|
||||
/**
|
||||
* Publish a previously-uploaded group file as a chat message via
|
||||
* `OidbSvcTrpcTcp.0x6d9_4`. The atomic upload+publish flow inside
|
||||
* `uploadGroupFile` already does this, but the OneBot send-message
|
||||
* path needs it too for {type:'file', file_id} segments.
|
||||
*/
|
||||
sendGroupFileMessage(groupId: number, fileId: string): Promise<void>;
|
||||
// ─── Files (moved to apis.groupFile) ───
|
||||
// - upload / uploadPrivate / publish
|
||||
// - list / getCount
|
||||
// - getUrl / getPrivateUrl / getPttUrl / getPrivatePttUrl
|
||||
// - getVideoUrl / getPrivateVideoUrl
|
||||
// - delete / move / createFolder / deleteFolder / renameFolder
|
||||
/** Cache file metadata so a later send_msg with just `file_id` can rehydrate it. */
|
||||
rememberUploadedFile(meta: UploadedFileMeta): void;
|
||||
recallUploadedFile(fileId: string): UploadedFileMeta | undefined;
|
||||
fetchGroupFiles(groupId: number, folderId?: string): Promise<GroupFilesResult>;
|
||||
fetchGroupFileUrl(groupId: number, fileId: string, busId?: number): Promise<string>;
|
||||
fetchPrivateFileUrl(userId: number, fileId: string, fileHash: string): Promise<string>;
|
||||
fetchGroupPttUrlByNode(groupId: number, node: MediaIndexNode): Promise<string>;
|
||||
fetchPrivatePttUrlByNode(node: MediaIndexNode): Promise<string>;
|
||||
fetchGroupVideoUrlByNode(groupId: number, node: MediaIndexNode): Promise<string>;
|
||||
fetchPrivateVideoUrlByNode(node: MediaIndexNode): Promise<string>;
|
||||
deleteGroupFile(groupId: number, fileId: string): Promise<void>;
|
||||
moveGroupFile(groupId: number, fileId: string, parentDirectory: string, targetDirectory: string): Promise<void>;
|
||||
createGroupFileFolder(groupId: number, name: string, parentId?: string): Promise<void>;
|
||||
deleteGroupFileFolder(groupId: number, folderId: string): Promise<void>;
|
||||
renameGroupFileFolder(groupId: number, folderId: string, newFolderName: string): Promise<void>;
|
||||
fetchGroupFileCount(groupId: number): Promise<{ fileCount: number; maxCount: number }>;
|
||||
|
||||
// ─── Group Album ───
|
||||
getGroupAlbumList(groupId: number): Promise<any>;
|
||||
|
||||
Reference in new issue
Block a user