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:
3 files changed
+43
-28
No files matched your search
@@ -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