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:
DrSmoothl committed 2026-08-17 19:40:22 +08:00
1 parent b63c3c370b
commit cc517080be
4 files changed
+22 -22

No files matched your search

@@ -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,
},
});