fix(protocol): set group robot-add options when values are off
Closes #386. Turning the options off no longer produces an empty request the server rejects.
This commit is contained in:
@@ -1,23 +1,17 @@
|
||||
// Group ext-info modify (robot-add option), RE'd from QQNT
|
||||
// wrapper.linux.node — OidbSvcTrpcTcp.0xf00_3 (modifyGroupExtInfoV2,
|
||||
// codec `group_ext_list_modify_codec.cc`). Worker ctor sub_4180800 passes
|
||||
// cmd=0xf00, sub=3, flag=1 (uin form).
|
||||
// Group ext-info modify (robot-add option).
|
||||
// OidbSvcTrpcTcp.0xf00_3 / modifyGroupExtInfoV2.
|
||||
//
|
||||
// Wire (EncodeModifyGroupExtInfoReq sub_4180B80 + ...Params sub_4180980):
|
||||
// ModifyGroupExtInfoReq{ 1:groupCode, 2:GroupExtInfo{ 1:groupCode,
|
||||
// 2:EXTInfo{ 30:inviteRobotMemberSwitch, 31:inviteRobotMemberExamine } } }
|
||||
// The GroupExtFilter that modifyGroupExtInfoV2 takes as its 2nd arg is
|
||||
// CLIENT-SIDE ONLY (it gates which EXTInfo fields the encoder emits); it is
|
||||
// NOT a wire field. So presence of EXTInfo tag 30/31 IS the write signal.
|
||||
// NOTE: proto3 omits zero-valued scalars, so a value of 0 will not transmit;
|
||||
// the robot toggles are non-zero in practice (QQ avoids 0 for set-states).
|
||||
// Response (DecodeModifyGroupExtInfoRsp sub_4180DB0): {1:groupCode, 2:result}.
|
||||
// Wire: ModifyGroupExtInfoReq{ 1:groupCode, 2:GroupExtInfo{ 1:groupCode,
|
||||
// 2:EXTInfo{ 29:inviteRobotMemberSwitch, 30:inviteRobotMemberExamine } } }
|
||||
// GroupExtFilter is client-side only: it decides which EXTInfo fields the
|
||||
// encoder emits. Presence of tag 29/30 IS the write signal, including 0.
|
||||
// Response: {1:groupCode, 2:result}.
|
||||
|
||||
import type { pb, int_32, uint_32 } from '@snowluma/proton';
|
||||
import type { pb, pb_optional, int_32, uint_32 } from '@snowluma/proton';
|
||||
|
||||
export interface OidbGroupExtBody {
|
||||
inviteRobotMemberSwitch?: pb<30, uint_32>;
|
||||
inviteRobotMemberExamine?: pb<31, uint_32>;
|
||||
inviteRobotMemberSwitch?: pb_optional<29, uint_32>;
|
||||
inviteRobotMemberExamine?: pb_optional<30, uint_32>;
|
||||
}
|
||||
export interface OidbGroupExtInfo {
|
||||
groupCode?: pb<1, uint_32>;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// 0xf00_3 — modifyGroupExtInfoV2, used for set_group_robot_add_option.
|
||||
// RE'd from QQNT group_ext_list_modify_codec.cc:
|
||||
// ModifyGroupExtInfoReq{ 1:groupCode, 2:GroupExtInfo{ 1:groupCode,
|
||||
// 2:EXTInfo{ 30:inviteRobotMemberSwitch, 31:inviteRobotMemberExamine } } }
|
||||
// The NT GroupExtFilter (2nd kernel arg) is client-side only — it just gates
|
||||
// which EXTInfo fields the encoder emits — so we mirror that by only setting
|
||||
// the fields the caller provides. uin-form OIDB (envelope reserved=1).
|
||||
// 2:EXTInfo{ 29:inviteRobotMemberSwitch, 30:inviteRobotMemberExamine } } }
|
||||
// GroupExtFilter is client-side only — it gates which EXTInfo fields the
|
||||
// encoder emits, including a value of 0. We only set the fields the caller
|
||||
// provides. uin-form OIDB (envelope reserved=1).
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
@@ -50,6 +49,10 @@ export namespace ModifyGroupExtInfo {
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbModifyGroupExtResp> =>
|
||||
protobuf_decode<OidbBase<OidbModifyGroupExtResp>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, ModifyGroupExtInfo, params);
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> => {
|
||||
if (params.robotMemberSwitch === undefined && params.robotMemberExamine === undefined) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return invokeOidb(deps, ModifyGroupExtInfo, params);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,24 +29,42 @@ describe('ModifyGroupExtInfo namespace', () => {
|
||||
.toEqual({ groupCode: 1, info: { groupCode: 1, ext: {} } });
|
||||
});
|
||||
|
||||
it('byte-oracle: routes to 0xf00_3 and locks nested tags {1:gc,2:{1:gc,2:{30:switch,31:examine}}}', async () => {
|
||||
it('byte-oracle: routes to 0xf00_3 and locks nested tags {1:gc,2:{1:gc,2:{29:switch,30:examine}}}', async () => {
|
||||
const sender = makeSender();
|
||||
await ModifyGroupExtInfo.invoke(sender, { groupId: 12345, robotMemberSwitch: 1, robotMemberExamine: 2 });
|
||||
|
||||
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0xf00_3');
|
||||
const ext = [...v(30, 1), ...v(31, 2)];
|
||||
const ext = [...v(29, 1), ...v(30, 2)];
|
||||
const info = [...v(1, 12345), ...m(2, ext)];
|
||||
const body = [...v(1, 12345), ...m(2, info)];
|
||||
expect(Buffer.from(bytes).toString('hex')).toBe(env(0xF00, 3, body, true));
|
||||
});
|
||||
|
||||
it('CAVEAT: a value of 0 is omitted on the wire (proto3 default) — documents the disable edge', async () => {
|
||||
it('emits switch=0 on the wire (explicit presence; omit would look like "unchanged")', async () => {
|
||||
const sender = makeSender();
|
||||
await ModifyGroupExtInfo.invoke(sender, { groupId: 12345, robotMemberSwitch: 0 });
|
||||
const [, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
// tag 30 varint = 0xF0 0x01; with value 0 it must NOT appear on the wire.
|
||||
expect(Buffer.from(bytes).toString('hex')).not.toContain('f001');
|
||||
const ext = [...v(29, 0)];
|
||||
const info = [...v(1, 12345), ...m(2, ext)];
|
||||
const body = [...v(1, 12345), ...m(2, info)];
|
||||
expect(Buffer.from(bytes).toString('hex')).toBe(env(0xF00, 3, body, true));
|
||||
});
|
||||
|
||||
it('emits both zeros when the caller sets switch and examine to 0', async () => {
|
||||
const sender = makeSender();
|
||||
await ModifyGroupExtInfo.invoke(sender, { groupId: 12345, robotMemberSwitch: 0, robotMemberExamine: 0 });
|
||||
const [, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
const ext = [...v(29, 0), ...v(30, 0)];
|
||||
const info = [...v(1, 12345), ...m(2, ext)];
|
||||
const body = [...v(1, 12345), ...m(2, info)];
|
||||
expect(Buffer.from(bytes).toString('hex')).toBe(env(0xF00, 3, body, true));
|
||||
});
|
||||
|
||||
it('does not send when neither field is provided', async () => {
|
||||
const sender = makeSender();
|
||||
await ModifyGroupExtInfo.invoke(sender, { groupId: 12345 });
|
||||
expect(sender.sendRawPacket).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('deserialize throws on a non-zero body result', () => {
|
||||
|
||||
Reference in New Issue
Block a user