fix(protocol): treat history visibility replies as an on/off flag
The group-detail reply reports whether new members can see history as a simple yes/no value. The write still flips that setting; the read no longer expects a multi-bit field.
This commit is contained in:
4 files changed
+22
-22
No files matched your search
@@ -365,7 +365,7 @@ export interface OidbGroupDetailFlags {
|
||||
shutUpAllTimestamp?: pb<45, bool>;
|
||||
/** Current complete app privilege bitfield; needed for masked mutations. */
|
||||
privilegeFlag?: pb<99, bool>;
|
||||
/** Current complete groupFlagExt4 bitfield; needed for masked mutations. */
|
||||
/** Request the new-member history-visible switch. */
|
||||
groupFlagExt4?: pb<101, bool>;
|
||||
noFingerOpen?: pb<82, bool>;
|
||||
noCodeFingerOpen?: pb<83, bool>;
|
||||
|
||||
@@ -128,7 +128,7 @@ export interface OidbSvcTrpcTcp0x88D_0Results {
|
||||
shutUpAllTimestamp?: pb<45, uint_32>;
|
||||
/** Complete app privilege bitfield (requested with detail flag tag 99). */
|
||||
privilegeFlag?: pb<99, uint_32>;
|
||||
/** Complete groupFlagExt4 bitfield (requested with detail flag tag 101). */
|
||||
/** New-member history-visible switch (0/1; omitted means hidden). */
|
||||
groupFlagExt4?: pb<101, uint_32>;
|
||||
// DecodeSingleGroupDetailInfoByBaseFilter: tag 82 → 60282, tag 83 → 60283.
|
||||
// SET counterparts are 0x89A settings 35/36. 0 = that search mode is open.
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
// 0x89A_0 — control whether newly joined members may browse group history.
|
||||
// QQ sends the complete current groupFlagExt4 value with a mutation mask, so
|
||||
// callers must read the flag before invoking this namespace.
|
||||
// Mutation writes the extended-flag value plus a one-bit mask. The matching
|
||||
// group-detail reply is a 0/1 switch (omitted means hidden), not the full
|
||||
// extended-flag bitfield.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
@@ -24,7 +25,8 @@ export function mergeGroupHistoryVisibility(currentGroupFlagExt4: number, visibl
|
||||
|
||||
export function decodeGroupHistoryVisibility(groupFlagExt4: number): boolean {
|
||||
assertUint32(groupFlagExt4, 'group history flag');
|
||||
return (groupFlagExt4 & GROUP_HISTORY_VISIBILITY_MASK) !== 0;
|
||||
// Detail replies use 0/1. The mutation bitfield still uses bit 2.
|
||||
return groupFlagExt4 === 1 || (groupFlagExt4 & GROUP_HISTORY_VISIBILITY_MASK) !== 0;
|
||||
}
|
||||
|
||||
export namespace SetNewMemberHistoryVisibility {
|
||||
@@ -33,7 +35,6 @@ export namespace SetNewMemberHistoryVisibility {
|
||||
|
||||
export interface Params {
|
||||
groupId: number;
|
||||
currentGroupFlagExt4: number;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ export namespace SetNewMemberHistoryVisibility {
|
||||
export const serialize = (_ctx: Deps, p: Params): Oidb0x89a_0HistoryVisibility => ({
|
||||
groupUin: BigInt(p.groupId),
|
||||
settings: {
|
||||
groupFlagExt4: mergeGroupHistoryVisibility(p.currentGroupFlagExt4, p.visible),
|
||||
groupFlagExt4: p.visible ? GROUP_HISTORY_VISIBILITY_MASK : 0,
|
||||
groupFlagExt4Mask: GROUP_HISTORY_VISIBILITY_MASK,
|
||||
},
|
||||
});
|
||||
|
||||
+14
-15
@@ -24,14 +24,13 @@ function makeSender() {
|
||||
|
||||
describe('SetNewMemberHistoryVisibility namespace', () => {
|
||||
it.each([
|
||||
[true, 0x80000001, 0x80000005],
|
||||
[false, 0x80000005, 0x80000001],
|
||||
])('writes visible=%s without changing unrelated bits', async (visible, current, expected) => {
|
||||
[true, GROUP_HISTORY_VISIBILITY_MASK],
|
||||
[false, 0],
|
||||
])('writes visible=%s as the mutation bit only', async (visible, expected) => {
|
||||
const sender = makeSender();
|
||||
|
||||
await SetNewMemberHistoryVisibility.invoke(sender, {
|
||||
groupId: 12345,
|
||||
currentGroupFlagExt4: current,
|
||||
visible,
|
||||
});
|
||||
|
||||
@@ -53,10 +52,12 @@ describe('SetNewMemberHistoryVisibility namespace', () => {
|
||||
expect(mergeGroupHistoryVisibility(0xF0000005, false)).toBe(0xF0000001);
|
||||
});
|
||||
|
||||
it('decodes the history-visibility bit', () => {
|
||||
it('decodes the history-visibility switch from a 0/1 reply or the mutation bit', () => {
|
||||
expect(decodeGroupHistoryVisibility(0)).toBe(false);
|
||||
expect(decodeGroupHistoryVisibility(1)).toBe(true);
|
||||
expect(decodeGroupHistoryVisibility(GROUP_HISTORY_VISIBILITY_MASK)).toBe(true);
|
||||
expect(decodeGroupHistoryVisibility(0x80000001)).toBe(false);
|
||||
expect(decodeGroupHistoryVisibility(0x80000005)).toBe(true);
|
||||
expect(decodeGroupHistoryVisibility(0)).toBe(false);
|
||||
});
|
||||
|
||||
it('round-trips history visibility through merge then decode', () => {
|
||||
@@ -64,11 +65,15 @@ describe('SetNewMemberHistoryVisibility namespace', () => {
|
||||
expect(decodeGroupHistoryVisibility(mergeGroupHistoryVisibility(0x80000005, false))).toBe(false);
|
||||
});
|
||||
|
||||
it('does not treat a 0/1 detail reply as a missing mutation bit (#387)', () => {
|
||||
expect(decodeGroupHistoryVisibility(1)).toBe(true);
|
||||
expect(decodeGroupHistoryVisibility(mergeGroupHistoryVisibility(0, true))).toBe(true);
|
||||
});
|
||||
|
||||
it('keeps an explicit zero value on the wire', async () => {
|
||||
const sender = makeSender();
|
||||
await SetNewMemberHistoryVisibility.invoke(sender, {
|
||||
groupId: 1,
|
||||
currentGroupFlagExt4: GROUP_HISTORY_VISIBILITY_MASK,
|
||||
visible: false,
|
||||
});
|
||||
|
||||
@@ -79,13 +84,7 @@ describe('SetNewMemberHistoryVisibility namespace', () => {
|
||||
expect(envelope.body?.settings?.groupFlagExt4Mask).toBe(GROUP_HISTORY_VISIBILITY_MASK);
|
||||
});
|
||||
|
||||
it('rejects an invalid current flag before sending', async () => {
|
||||
const sender = makeSender();
|
||||
await expect(SetNewMemberHistoryVisibility.invoke(sender, {
|
||||
groupId: 1,
|
||||
currentGroupFlagExt4: -1,
|
||||
visible: true,
|
||||
})).rejects.toThrow(/unsigned 32-bit/);
|
||||
expect(sender.sendRawPacket).not.toHaveBeenCalled();
|
||||
it('rejects an invalid current flag when merging', () => {
|
||||
expect(() => mergeGroupHistoryVisibility(-1, true)).toThrow(/unsigned 32-bit/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user