Splits the 14 OIDB cmds from GroupAdminApi into self-contained
namespaces under @snowluma/bridge/oidb-services/group-admin/. The
facade becomes one-line forwarders; per-cmd capability is narrowed
to OidbSender (+ resolveUserUid / identity where the cmd actually
needs it).
Notes:
- 0x89A_0 hosts MuteAll, SetAddOption, SetSearch, SetGroupName —
same (cmd, subcmd) tuple, four different proto bodies; each gets
its own namespace so proton can monomorphize independently.
- 0x8A0_1 splits KickMember (single) and KickMembers (batch) for
the same reason.
- SetAddRequest carries uinForm=true and dynamic subCommand
(filtered ? 2 : 1) on the same namespace.
- GetAtAllRemain needs the bot's own uin → declares
Pick<BridgeContext, 'identity'> in its Deps.
Wire-byte equivalence preserved; corner case for getAtAllRemain
empty-envelope path now returns {false, 0, 0} instead of throwing —
the new infrastructure normalises empty bodies and the OneBot action
ergonomics are unchanged.
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
// 0x1096_1 — promote / demote a member to/from group administrator.
|
|
|
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
|
import type { OidbSetAdmin } from '@snowluma/proto-defs/oidb-actions/base';
|
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
|
import type { BridgeContext } from '../../bridge-context';
|
|
|
|
export namespace SetAdmin {
|
|
export const command = 0x1096;
|
|
export const subCommand = 1;
|
|
|
|
export interface Params { groupId: number; userId: number; enable: boolean; }
|
|
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
|
|
|
|
export const serialize = (p: Params, uid: string): OidbSetAdmin => ({
|
|
groupUin: p.groupId, uid, isAdmin: p.enable,
|
|
});
|
|
|
|
export const deserialize = (_: OidbEmpty): void => {};
|
|
export const encode = (env: OidbBase<OidbSetAdmin>): Uint8Array =>
|
|
protobuf_encode<OidbBase<OidbSetAdmin>>(env);
|
|
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
|
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
|
|
|
export const invoke = async (deps: Deps, params: Params): Promise<void> => {
|
|
const uid = await deps.resolveUserUid(params.userId, params.groupId);
|
|
await invokeOidb(deps, { ...SetAdmin, serialize: p => serialize(p, uid) }, params);
|
|
};
|
|
}
|