refactor(api): move 2 forward methods to ForwardApi (#6 commit 9/13)
Inlines `actions/forward.ts` into `apis/forward.ts::ForwardApi`. The
file is the largest unmoved one — 475 lines covering long-message
upload with NapCat-style piggyback for nested {type:"node"} chains,
plus the cached fetch side.
The module-scoped `forwardResCache` Map stays at file scope rather
than as an instance field. Forward res_ids are globally unique and
an outbound upload often gets queried back through `fetch` on a
different Bridge instance (different OneBot connection hitting the
same account) — NapCat's behaviour relies on the cache being shared
across the process.
Method renaming (Api namespace already says "forward"):
uploadForwardNodes → upload
fetchForwardNodes → fetch
The private `uploadForwardNodesRecursive` becomes
`this.uploadRecursive(...)` — same body, threads through `this.ctx`.
Callers updated: `modules/message-actions.ts` (4 sites).
Tests rewritten:
- `forward.test.ts` → `new ForwardApi(bridge as any).upload/fetch(...)`
- `forward-file.test.ts` → same pattern
- `forward-nested.test.ts` → mocks `apis.forward.upload` instead of
flat `bridge.uploadForwardNodes`
587/587 tests pass.
This commit is contained in:
1 parent
62c5590fe1
commit
d953b9824c
9 files changed
+523
-510
No files matched your search
@@ -7,7 +7,6 @@ import type {
|
||||
UploadedFileMeta,
|
||||
} from './bridge';
|
||||
import type { BridgeEventBus } from './event-bus';
|
||||
import type { ForwardNodePayload } from './events';
|
||||
import type { IdentityService } from './identity-service';
|
||||
import type { WebHonorType } from './web/group-honor';
|
||||
|
||||
@@ -62,9 +61,8 @@ export interface BridgeInterface {
|
||||
// ─── Group Album (moved to apis.groupAlbum) ───
|
||||
// - list / upload / getMediaList / comment / like / delete
|
||||
|
||||
// ─── Forward ───
|
||||
uploadForwardNodes(nodes: ForwardNodePayload[], groupId?: number, userId?: number): Promise<string>;
|
||||
fetchForwardNodes(resId: string): Promise<ForwardNodePayload[]>;
|
||||
// ─── Forward (moved to apis.forward) ───
|
||||
// - upload / fetch
|
||||
|
||||
// ─── Message ops (moved to apis.message) ───
|
||||
|
||||
|
||||
Reference in new issue
Block a user