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
@@ -1,7 +1,6 @@
|
||||
import type { PacketSender, SendPacketResult } from '../protocol/packet-sender';
|
||||
import type { PacketInfo } from '../protocol/types';
|
||||
import type { BridgeInterface } from './bridge-interface';
|
||||
import type { ForwardNodePayload } from './events';
|
||||
import { IdentityService } from './identity-service';
|
||||
import { MSG_PUSH_CMD, parseMsgPush } from './msg-push';
|
||||
import { IncomingPacketPipeline, type CmdParser } from './packet-pipeline';
|
||||
@@ -22,10 +21,7 @@ import {
|
||||
type AiVoiceChatType as AiVoiceChatTypeT,
|
||||
type StrangerStatus,
|
||||
} from './actions/extras';
|
||||
import {
|
||||
fetchForwardNodes as fetchForwardNodes_,
|
||||
uploadForwardNodes as uploadForwardNodes_,
|
||||
} from './actions/forward';
|
||||
// actions/forward.ts removed — moved to apis/forward.ts::ForwardApi.
|
||||
// actions/friend.ts removed — moved to apis/friend.ts::FriendApi.
|
||||
// actions/group-admin.ts removed — moved to `apis/group-admin.ts::GroupAdminApi`.
|
||||
// actions/group-album.ts removed — moved to `apis/group-album.ts::GroupAlbumApi`.
|
||||
@@ -309,8 +305,7 @@ export class Bridge implements BridgeInterface {
|
||||
// getPrivateUrl/{Ptt,Video}Url/getPrivate{Ptt,Video}Url/delete/move/
|
||||
// createFolder/deleteFolder/renameFolder/getCount) moved to
|
||||
// apis.groupFile (apis/group-file.ts::GroupFileApi).
|
||||
async uploadForwardNodes(nodes: ForwardNodePayload[], groupId?: number, userId?: number): Promise<string> { return uploadForwardNodes_(this, nodes, groupId, userId); }
|
||||
async fetchForwardNodes(resId: string): Promise<ForwardNodePayload[]> { return fetchForwardNodes_(this, resId); }
|
||||
// Forward methods (upload / fetch) moved to apis.forward.
|
||||
// Interaction methods (sendPoke/sendLike/setReaction/setEssence/
|
||||
// getEmojiLikes) moved to apis.interaction.
|
||||
// recall* / markRead* moved to apis/message.ts::MessageApi.
|
||||
|
||||
Reference in new issue
Block a user