refactor(oidb): migrate interaction.ts remaining 3 cmds to namespaces
Completes the InteractionApi facade — every method is now a one-line
forwarder. New namespaces:
- SendPoke (0xED3_1) — group + friend variants discriminated by
which of groupUin/friendUin is set
- SendLike (0x7E5_104) — thumbs-up to a target user
- SetEssence (0xEAC_1/_2) — set/unset essence message, dynamic subcmd
Facade methods reduced to thin forwarders, mirror-fixed comment block
removed (the namespaces now own the wire-shape commentary).
Tests: 28 new in @snowluma/bridge covering each namespace's serialize
edge cases + dynamic subcmd resolution + e2e wire name + envelope body
shape. Cleaned the legacy `vi.mock('bridge-oidb')` setup out of
interaction.test.ts — the post-migration path doesn't route through
the mocked symbols anymore.
Wire behavior unchanged: every cmd produces the same bytes as before,
verified by encode round-trip in the unit tests.
This commit is contained in:
9 files changed
+354
-93
No files matched your search
@@ -0,0 +1,37 @@
|
||||
// 0x7E5_104 — send "thumbs up" (赞) to another user (friend list 点赞).
|
||||
//
|
||||
// `count` is the number of likes in this single call (QQ allows
|
||||
// 1–20 batched). Server caps daily quotas separately.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbLike } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace SendLike {
|
||||
export const command = 0x7E5;
|
||||
export const subCommand = 104;
|
||||
|
||||
export interface Params {
|
||||
userId: number;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (p: Params): OidbLike => ({
|
||||
targetUin: p.userId,
|
||||
count: p.count,
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
|
||||
export const encode = (env: OidbBase<OidbLike>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbLike>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, SendLike, params);
|
||||
}
|
||||
Reference in new issue
Block a user