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:
DrSmoothl committed 2026-05-20 23:08:50 +08:00
1 parent 0b91e4db8d
commit dad501ebc0
17 files changed
+1241 -1185

No files matched your search

@@ -114,7 +114,7 @@ export async function getGroupFiles(
groupId: number,
folderId?: string,
): Promise<JsonObject> {
const result = await bridge.fetchGroupFiles(groupId, folderId ?? '/');
const result = await bridge.apis.groupFile.list(groupId, folderId ?? '/');
return {
files: result.files.map((file) => ({
group_id: groupId as any,
@@ -34,8 +34,8 @@ export async function getRecordInfo(
if (!url && cached.mediaNode) {
try {
url = cached.isGroup
? await bridge.fetchGroupPttUrlByNode(cached.sessionId, cached.mediaNode)
: await bridge.fetchPrivatePttUrlByNode(cached.mediaNode);
? await bridge.apis.groupFile.getPttUrl(cached.sessionId, cached.mediaNode)
: await bridge.apis.groupFile.getPrivatePttUrl(cached.mediaNode);
if (url) {
mediaStore.updateRecordUrl(file, url);
}
@@ -269,7 +269,7 @@ export async function sendGroupMessage(
// wire. If this is the LAST element we still need a receipt so
// the OneBot caller can cache the id; synthesise one from the
// file_id hash + a fresh timestamp.
await ref.bridge.sendGroupFileMessage(groupId, fileEl.fileId!);
await ref.bridge.apis.groupFile.publish(groupId, fileEl.fileId!);
logSentMessage(true, groupId, [fileEl]);
if (!lastReceipt) {
// Use a hash of the fileId as a stable pseudo-id; this gets