fix(protocol): read group mute expire from official proto tags (#356)
get_group_info / get_group_list mapped FE5 tag 31 and 88D tag 59 as shutUpAllTimestamp, then treated any >0 value as muted. Official wrapper.node maps those tags to internal 60259; the real expire (60027 / groupShutupExpireTime) is FE5 tag 10 and 88D tag 45 (request mask 45). After a group had been muted, 60259 often stayed nonzero so group_all_shut stuck at -1. Read the 60027 tags and treat all-mute as expire > now (0xFFFFFFFF is permanent). Fixes #356
This commit is contained in:
8 files changed
+93
-12
No files matched your search
@@ -34,6 +34,13 @@ import type { BridgeContext } from '../bridge-context';
|
||||
|
||||
const log = createLogger('Bridge.Contacts');
|
||||
|
||||
// Official client stores group mute as an expire timestamp (internal 60027 /
|
||||
// JS groupShutupExpireTime): 0 = off, 0xFFFFFFFF = permanent, otherwise unix
|
||||
// seconds. `> 0` is wrong — a leftover past expire still looks "on".
|
||||
function isGroupAllMuted(expireTs?: number, nowSec = Math.floor(Date.now() / 1000)): boolean {
|
||||
return (expireTs ?? 0) > nowSec;
|
||||
}
|
||||
|
||||
// ─── Helpers (previously in bridge-contacts.ts) ───────────────────
|
||||
|
||||
type FriendPropertySource = {
|
||||
@@ -310,7 +317,7 @@ export class ContactsApi {
|
||||
// is not in the list (0x88D_0 detail only), so it stays undefined here.
|
||||
createTime: raw.info?.createdTime ?? 0,
|
||||
memo: raw.info?.announcement || raw.info?.description || '',
|
||||
allMuted: (raw.info?.shutUpAllTimestamp ?? 0) > 0,
|
||||
allMuted: isGroupAllMuted(raw.info?.shutUpAllTimestamp),
|
||||
});
|
||||
}
|
||||
this.ctx.identity.rememberGroups(groups);
|
||||
@@ -341,7 +348,7 @@ export class ContactsApi {
|
||||
createTime: Number(r.createTime ?? 0n),
|
||||
level: Number(r.level ?? 0n),
|
||||
memo: r.noticePreview ?? '',
|
||||
allMuted: (r.shutUpAllTimestamp ?? 0) > 0,
|
||||
allMuted: isGroupAllMuted(r.shutUpAllTimestamp),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +269,25 @@ describe('apis/contacts / group roster', () => {
|
||||
allMuted: true,
|
||||
}));
|
||||
});
|
||||
|
||||
it('treats a past group-mute expire as unmuted (#356)', async () => {
|
||||
const sendRawPacket = vi.fn(async () => groupListPacket({
|
||||
groups: [{
|
||||
groupUin: 123456789,
|
||||
info: {
|
||||
groupName: 'Was Muted',
|
||||
shutUpAllTimestamp: 1_700_000_000,
|
||||
},
|
||||
}],
|
||||
}));
|
||||
const api = new ContactsApi({
|
||||
sendRawPacket,
|
||||
identity: { rememberGroups: vi.fn() },
|
||||
} as any);
|
||||
|
||||
const groups = await api.fetchGroupList();
|
||||
expect(groups[0]?.allMuted).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('apis/contacts / group requests', () => {
|
||||
|
||||
@@ -352,7 +352,9 @@ export interface OidbGroupDetailFlags {
|
||||
question?: pb<24, bool>;
|
||||
answer?: pb<25, string>;
|
||||
maxAdminCount?: pb<29, string>;
|
||||
shutUpAllTimestamp?: pb<59, bool>;
|
||||
// Official request mask for group shutup expire (proto tag 45 → 60027).
|
||||
// Lagrange's tag 59 requests 60259, which is a different field.
|
||||
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. */
|
||||
|
||||
@@ -82,7 +82,10 @@ export interface OidbSvcTrpcTcp0xFE5_2GroupInfo {
|
||||
description?: pb<18, string>;
|
||||
question?: pb<19, string>;
|
||||
announcement?: pb<30, string>;
|
||||
shutUpAllTimestamp?: pb<31, uint_32>;
|
||||
// wrapper.node 3.2.32 group_codec.cc DecodeGroupInfo: tag 10 → internal
|
||||
// 60027 (JS groupShutupExpireTime). Tag 31 is 60259, not the mute expire.
|
||||
// 0 = off, 0xFFFFFFFF = permanent, otherwise unix-seconds expire.
|
||||
shutUpAllTimestamp?: pb<10, uint_32>;
|
||||
}
|
||||
|
||||
export interface OidbSvcTrpcTcp0xFE5_2CustomInfo {
|
||||
@@ -116,7 +119,10 @@ export interface OidbSvcTrpcTcp0x88D_0Results {
|
||||
question?: pb<24, string>;
|
||||
answer?: pb<25, string>;
|
||||
maxAdminCount?: pb<29, uint_64>;
|
||||
shutUpAllTimestamp?: pb<59, uint_32>;
|
||||
// wrapper.node 3.2.32 group_info_fetch_codec.cc
|
||||
// DecodeSingleGroupDetailInfoByBaseFilter: tag 45 → internal 60027.
|
||||
// Tag 59 is 60259, not the mute expire. Request mask tag is also 45.
|
||||
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). */
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
// including ones the bot hasn't joined — used to put a name on a group invite
|
||||
// (where the invite push itself carries no group name). The `flags` block is a
|
||||
// request mask: a present bool(true)/string("") asks the server to include that
|
||||
// field in the response. Cross-checked against
|
||||
// dev/Lagrange.Core/.../GetGroupInfoService.cs — note it builds the envelope
|
||||
// with isUid=false, i.e. reserved=0 (NO uinForm), unlike the 0xFE5_2 list query.
|
||||
// field in the response. Envelope is reserved=0 (NO uinForm), unlike 0xFE5_2.
|
||||
// Mute expire request/response tag is 45 (official 60027), not Lagrange's 59.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbSvcTrpcTcp0x88D_0Response } from '@snowluma/proto-defs/oidb';
|
||||
@@ -33,6 +32,7 @@ export namespace FetchGroupDetail {
|
||||
ownerUid: on, createTime: on, maxMemberCount: on, memberCount: on,
|
||||
level: on, name: '', noticePreview: '', uin: on, lastSequence: on,
|
||||
lastMessageTime: on, question: on, answer: '', maxAdminCount: '',
|
||||
// Tag 45 (not Lagrange's 59): official request mask for 60027.
|
||||
shutUpAllTimestamp: on, privilegeFlag: on, groupFlagExt4: on,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -57,7 +57,7 @@ export interface QQGroupInfo {
|
||||
level?: number;
|
||||
/** Group memo / announcement preview. '' when unknown (#197). */
|
||||
memo?: string;
|
||||
/** Whether the group currently has group-wide mute enabled. */
|
||||
/** Whether group-wide mute is currently in effect (expire still in the future). */
|
||||
allMuted?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ import { FetchGroupDetail } from '../../../src/oidb-services/contacts/fetch-grou
|
||||
|
||||
interface GroupDetailResultsFixture {
|
||||
name?: pb<15, string>;
|
||||
shutUpAllTimestamp?: pb<59, uint_32>;
|
||||
shutUpAllTimestamp?: pb<45, uint_32>;
|
||||
leftover59?: pb<59, uint_32>;
|
||||
privilegeFlag?: pb<99, uint_32>;
|
||||
groupFlagExt4?: pb<101, uint_32>;
|
||||
}
|
||||
@@ -116,6 +117,28 @@ describe('FetchGroupDetail namespace', () => {
|
||||
expect(out.groupInfo?.results?.shutUpAllTimestamp).toBe(4_294_967_295);
|
||||
});
|
||||
|
||||
it('does not treat 0x88D results tag 59 as the mute expire (#356)', async () => {
|
||||
const responseData = Buffer.from(protobuf_encode<OidbBase<GroupDetailResponseFixture>>({
|
||||
body: {
|
||||
groupInfo: {
|
||||
uin: 601692726n,
|
||||
results: { name: 'Unmuted Group', leftover59: 4_294_967_295 },
|
||||
},
|
||||
},
|
||||
}));
|
||||
const sender = makeSender();
|
||||
sender.sendRawPacket.mockResolvedValue({
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData,
|
||||
});
|
||||
|
||||
const out = await FetchGroupDetail.invoke(sender, { groupUin: 601692726 });
|
||||
expect(out.groupInfo?.results?.shutUpAllTimestamp ?? undefined).toBeUndefined();
|
||||
});
|
||||
|
||||
it('decodes the complete privilege flag used by masked group mutations', async () => {
|
||||
const responseData = Buffer.from(protobuf_encode<OidbBase<GroupDetailResponseFixture>>({
|
||||
body: {
|
||||
|
||||
@@ -14,7 +14,8 @@ import { FetchGroupList } from '../../../src/oidb-services/contacts/fetch-group-
|
||||
|
||||
interface GroupInfoFixture {
|
||||
groupName?: pb<5, string>;
|
||||
shutUpAllTimestamp?: pb<31, uint_32>;
|
||||
shutUpAllTimestamp?: pb<10, uint_32>;
|
||||
leftover31?: pb<31, uint_32>;
|
||||
}
|
||||
|
||||
interface GroupFixture {
|
||||
@@ -55,7 +56,7 @@ describe('FetchGroupList namespace', () => {
|
||||
const env = protobuf_decode<OidbBase<OidbGroupListRequest>>(bytes);
|
||||
expect(env.body?.config?.config1?.groupName).toBe(true);
|
||||
expect(env.body?.config?.config1?.memberCount).toBe(true);
|
||||
expect(env.body?.config?.config1?.field31).toBe(true);
|
||||
expect(env.body?.config?.config1?.field10).toBe(true);
|
||||
expect(env.body?.config?.config2?.remark).toBe(true);
|
||||
for (const field of ['field1', 'field2', 'field4', 'field5', 'field6', 'field7', 'field8'] as const) {
|
||||
expect(env.body?.config?.config2?.[field] ?? false, field).toBe(false);
|
||||
@@ -87,5 +88,28 @@ describe('FetchGroupList namespace', () => {
|
||||
|
||||
expect(out.groups?.[0]?.info?.shutUpAllTimestamp).toBe(4_294_967_295);
|
||||
});
|
||||
|
||||
it('does not treat 0xFE5 info tag 31 as the mute expire (#356)', async () => {
|
||||
const responseData = Buffer.from(protobuf_encode<OidbBase<GroupListFixture>>({
|
||||
body: {
|
||||
groups: [{
|
||||
groupUin: 123456789,
|
||||
info: { groupName: 'Unmuted Group', leftover31: 4_294_967_295 },
|
||||
}],
|
||||
},
|
||||
}));
|
||||
const sender = makeSender();
|
||||
sender.sendRawPacket.mockResolvedValue({
|
||||
success: true,
|
||||
gotResponse: true,
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
responseData,
|
||||
});
|
||||
|
||||
const out = await FetchGroupList.invoke(sender);
|
||||
|
||||
expect(out.groups?.[0]?.info?.shutUpAllTimestamp ?? undefined).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user