6 OIDB cmds moved; pagination + per-group cache + inflight
coalescing stay on the facade because they need cross-call state.
- FetchFriendListPage (0xFD4_1) — facade drives the cursor loop
- FetchGroupList (0xFE5_2) — uinForm; verbatim config blob
- FetchGroupMemberListPage (0xFE7_3) — facade drives the token loop +
owns the TTL cache + inflight
coalescing that keeps busy
OneBot clients from tripping
Tencent risk-control
- FetchUserProfile (0xFE1_2) — uinForm; full property-key
catalogue cross-checked against
LagrangeV2 FetchStrangerService.cs
- FetchGroupRequests (0x10C0_1/_2) — dynamic subcmd via filtered flag
- FetchDownloadRkeys (0x9067_202) — uinForm; respHead.retCode
check moved into deserialize
35 new namespace-level tests covering serialize / deserialize edge
cases (property decoding, sex enum mapping, avatar URL suffix,
empty body handling, pagination cursor behaviour).
Verification:
- typecheck green
- @snowluma/bridge: 30 files / 233 tests
- @snowluma/core: 302 tests
Wire bytes unchanged.
58 lines
2.4 KiB
TypeScript
58 lines
2.4 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { protobuf_decode } from '@snowluma/proton';
|
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
|
import type { OidbGroupMemberListRequest } from '@snowluma/proto-defs/oidb-actions/base';
|
|
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
|
|
|
import { FetchGroupMemberListPage } from '../../../src/oidb-services/contacts/fetch-group-member-list-page';
|
|
|
|
function makeSender() {
|
|
const r: SendPacketResult = { success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData: Buffer.alloc(0) };
|
|
return { sendRawPacket: vi.fn(async () => r) };
|
|
}
|
|
|
|
describe('FetchGroupMemberListPage namespace', () => {
|
|
it('declares 0xFE7_3', () => {
|
|
expect(FetchGroupMemberListPage.command).toBe(0xFE7);
|
|
expect(FetchGroupMemberListPage.subCommand).toBe(3);
|
|
});
|
|
|
|
describe('serialize', () => {
|
|
it('omits the token on the first page', () => {
|
|
const out = FetchGroupMemberListPage.serialize({ groupId: 12345, token: '' }) as any;
|
|
expect(out.token).toBeUndefined();
|
|
expect(out.groupUin).toBe(12345);
|
|
});
|
|
|
|
it('threads the server-issued token into follow-up pages', () => {
|
|
const out = FetchGroupMemberListPage.serialize({ groupId: 12345, token: 'next-cursor' }) as any;
|
|
expect(out.token).toBe('next-cursor');
|
|
});
|
|
|
|
it('always requests the full member-field projection', () => {
|
|
const out = FetchGroupMemberListPage.serialize({ groupId: 1, token: '' }) as any;
|
|
expect(out.body).toMatchObject({
|
|
memberName: true, memberCard: true, level: true,
|
|
joinTimestamp: true, lastMsgTimestamp: true, shutUpTimestamp: true,
|
|
permission: true,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('invoke (e2e)', () => {
|
|
it('routes to OidbSvcTrpcTcp.0xfe7_3', async () => {
|
|
const sender = makeSender();
|
|
await FetchGroupMemberListPage.invoke(sender, { groupId: 1, token: '' });
|
|
expect(sender.sendRawPacket.mock.calls[0]![0]).toBe('OidbSvcTrpcTcp.0xfe7_3');
|
|
});
|
|
|
|
it('encodes envelope body with the groupId', async () => {
|
|
const sender = makeSender();
|
|
await FetchGroupMemberListPage.invoke(sender, { groupId: 12345, token: '' });
|
|
const [, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
|
const env = protobuf_decode<OidbBase<OidbGroupMemberListRequest>>(bytes);
|
|
expect(env.body?.groupUin).toBe(12345);
|
|
});
|
|
});
|
|
});
|