feat(onebot): expose group-wide mute status

Report whether group-wide mute is enabled through the existing group list and group information responses.

Keep standard and extended queries aligned, support explicit refreshes in the SDK, and update the generated action documentation without adding another endpoint.

Preserve established compatibility values, isolate cached non-member results by account, and add coverage across the request, mapping, action, and client layers.

Closes #313
This commit is contained in:
DrSmoothl committed 2026-08-04 23:27:58 +08:00
1 parent c6619fda0a
commit 634097460c
18 files changed
+687 -56

No files matched your search

@@ -3,13 +3,33 @@
// matching Lagrange's GetGroupInfoService) and the response decode.
import { describe, expect, it, vi } from 'vitest';
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import {
protobuf_decode,
protobuf_encode,
type pb,
type uint_32,
type uint_64,
} from '@snowluma/proton';
import type { OidbBase, OidbSvcTrpcTcp0x88D_0Response } from '@snowluma/proto-defs/oidb';
import type { OidbGroupDetailRequest } from '@snowluma/proto-defs/oidb-actions/base';
import type { SendPacketResult } from '@snowluma/common/packet-sender';
import { FetchGroupDetail } from '../../../src/oidb-services/contacts/fetch-group-detail';
interface GroupDetailResultsFixture {
name?: pb<15, string>;
shutUpAllTimestamp?: pb<59, uint_32>;
}
interface GroupDetailInfoFixture {
uin?: pb<1, uint_64>;
results?: pb<3, GroupDetailResultsFixture>;
}
interface GroupDetailResponseFixture {
groupInfo?: pb<1, GroupDetailInfoFixture>;
}
function makeSender(body?: OidbSvcTrpcTcp0x88D_0Response) {
const responseData = body !== undefined
? Buffer.from(protobuf_encode<OidbBase<OidbSvcTrpcTcp0x88D_0Response>>({ body }))
@@ -33,6 +53,8 @@ describe('FetchGroupDetail namespace', () => {
expect(out.config?.flags?.name).toBe(''); // string mask → request the name
expect(out.config?.flags?.memberCount).toBe(true);
expect(out.config?.flags?.maxMemberCount).toBe(true);
expect((out.config?.flags as { shutUpAllTimestamp?: boolean })?.shutUpAllTimestamp)
.toBe(true);
});
});
@@ -66,5 +88,28 @@ describe('FetchGroupDetail namespace', () => {
expect(out.groupInfo?.results?.memberCount).toBe(42n);
expect(out.groupInfo?.results?.maxMemberCount).toBe(500n);
});
it('decodes the group-wide mute timestamp from a detail response', async () => {
const responseData = Buffer.from(protobuf_encode<OidbBase<GroupDetailResponseFixture>>({
body: {
groupInfo: {
uin: 601692726n,
results: { name: 'Muted Group', shutUpAllTimestamp: 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).toBe(4_294_967_295);
});
});
});
@@ -1,11 +1,31 @@
import { describe, expect, it, vi } from 'vitest';
import { protobuf_decode } from '@snowluma/proton';
import {
protobuf_decode,
protobuf_encode,
type pb,
type pb_repeated,
type uint_32,
} from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { OidbGroupListRequest } from '@snowluma/proto-defs/oidb-actions/base';
import type { SendPacketResult } from '@snowluma/common/packet-sender';
import { FetchGroupList } from '../../../src/oidb-services/contacts/fetch-group-list';
interface GroupInfoFixture {
groupName?: pb<5, string>;
shutUpAllTimestamp?: pb<31, uint_32>;
}
interface GroupFixture {
groupUin?: pb<3, uint_32>;
info?: pb<4, GroupInfoFixture>;
}
interface GroupListFixture {
groups?: pb_repeated<2, GroupFixture>;
}
function makeSender() {
const r: SendPacketResult = { success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData: Buffer.alloc(0) };
return { sendRawPacket: vi.fn(async () => r) };
@@ -35,6 +55,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?.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);
@@ -43,5 +64,28 @@ describe('FetchGroupList namespace', () => {
expect(env.body?.config?.config1?.field5002 ?? false).toBe(false);
expect(env.body?.config?.config1?.field5003 ?? false).toBe(false);
});
it('decodes the group-wide mute timestamp returned with the joined roster', async () => {
const responseData = Buffer.from(protobuf_encode<OidbBase<GroupListFixture>>({
body: {
groups: [{
groupUin: 123456789,
info: { groupName: 'Muted Group', shutUpAllTimestamp: 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).toBe(4_294_967_295);
});
});
});