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:
DrSmoothl committed 2026-05-22 23:22:26 +08:00
1 parent 0238bcb280
commit ff2b902cbd
9 files changed
+354 -93

No files matched your search

@@ -0,0 +1,44 @@
// 0xEAC — set / unset a group "essence" message (群精华).
// subCommand 1 = mark as essence, 2 = remove from essence
//
// `random` is the message's wire-level random field (carried through
// from the original send so the server can resolve the canonical
// message identity).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbEssence } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace SetEssence {
export const command = 0xEAC;
export interface Params {
groupId: number;
sequence: number;
random: number;
/** true = mark essence (subCmd 1), false = unmark (subCmd 2). */
enable: boolean;
}
export type Deps = OidbSender;
export const resolveSubCommand = (p: Params): number => p.enable ? 1 : 2;
export const serialize = (p: Params): OidbEssence => ({
groupUin: p.groupId,
sequence: p.sequence,
random: p.random,
});
export const deserialize = (_: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbEssence>): Uint8Array =>
protobuf_encode<OidbBase<OidbEssence>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetEssence, params);
}