refactor(oidb): migrate group-file.ts OIDB cmds to namespaces
Splits the 16 OIDB cmds from GroupFileApi into self-contained
namespaces under @snowluma/bridge/oidb-services/group-file/. Adds
@snowluma/bridge/oidb-services/shared with `toInt` / `ensureRetCodeZero`
helpers so namespaces can validate sub-responses without an
@snowluma/core dependency.
Boundaries:
- Single-OIDB methods (publish / getCount / list-page / *url /
delete / move / *folder) become one-line forwarders.
- 3-stage methods (`upload` / `uploadPrivate`) keep their
orchestration on the facade — OIDB preflight goes through the
new namespace, but highway PUT + publish/sendC2cFile + upload-
cache bookkeeping stay where they are.
- `list` keeps its pagination loop on the facade; the page-fetch
namespace is one call.
- The NTV2-rich-media URL fetchers (group/private × ptt/video)
share a deserialize helper (`parseNtv2DownloadUrl`) so all four
namespaces only differ in their scene block.
Wire-byte equivalence preserved. The 0x6D6 family shares one
OidbGroupFileReq envelope; each namespace populates a different
slot (file / download / delete / move) and proton monomorphizes
per call site as before.
This commit is contained in:
37 files changed
+1900
-564
No files matched your search
@@ -0,0 +1,47 @@
|
||||
// 0x6D6_5 — move a group file between folders.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
OidbGroupFileReq, OidbGroupFileResp,
|
||||
} from '@snowluma/proto-defs/oidb-actions/group-file';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import { ensureRetCodeZero } from '../shared';
|
||||
|
||||
export namespace MoveGroupFile {
|
||||
export const command = 0x6D6;
|
||||
export const subCommand = 5;
|
||||
export const uinForm = true;
|
||||
|
||||
export interface Params {
|
||||
groupId: number; fileId: string;
|
||||
parentDirectory: string; targetDirectory: string;
|
||||
}
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (p: Params): OidbGroupFileReq => ({
|
||||
move: {
|
||||
groupUin: p.groupId,
|
||||
appId: 7,
|
||||
busId: 102,
|
||||
fileId: p.fileId,
|
||||
parentDirectory: p.parentDirectory,
|
||||
targetDirectory: p.targetDirectory,
|
||||
},
|
||||
});
|
||||
|
||||
export const deserialize = (body: OidbGroupFileResp): void => {
|
||||
const result = body.move;
|
||||
if (!result) throw new Error('group file move response missing');
|
||||
ensureRetCodeZero('group file move', result.retCode, result.retMsg, result.clientWording);
|
||||
};
|
||||
|
||||
export const encode = (env: OidbBase<OidbGroupFileReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbGroupFileReq>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileResp> =>
|
||||
protobuf_decode<OidbBase<OidbGroupFileResp>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, MoveGroupFile, params);
|
||||
}
|
||||
Reference in new issue
Block a user