diff --git a/packages/core/src/bridge/apis/contacts.ts b/packages/core/src/bridge/apis/contacts.ts index 861ce2f8..f8a80572 100644 --- a/packages/core/src/bridge/apis/contacts.ts +++ b/packages/core/src/bridge/apis/contacts.ts @@ -3,7 +3,11 @@ import { FetchFriendListPage } from '@snowluma/protocol/oidb-services/contacts/f import { FetchGroupDetail } from '@snowluma/protocol/oidb-services/contacts/fetch-group-detail'; import { FetchGroupList } from '@snowluma/protocol/oidb-services/contacts/fetch-group-list'; import { FetchGroupMemberListPage } from '@snowluma/protocol/oidb-services/contacts/fetch-group-member-list-page'; -import { FetchGroupRequests } from '@snowluma/protocol/oidb-services/contacts/fetch-group-requests'; +import { + FetchGroupRequests, + FetchGroupRequestsByUid, + groupRequestOperationType, +} from '@snowluma/protocol/oidb-services/contacts/fetch-group-requests'; import { FetchRobotUinRanges, type RobotUinRange, @@ -92,6 +96,19 @@ export function isRobotUin(uin: number, ranges: readonly RobotUinRange[]): boole && ranges.some(({ minUin, maxUin }) => uin >= minUin && uin <= maxUin); } +function normalizeGroupRequestSequence( + rawSequence: bigint | number | undefined, + groupId: number, +): number { + const sequence = Number(rawSequence ?? 0); + if (!Number.isSafeInteger(sequence) || sequence <= 0) { + throw new Error( + `invalid group-request sequence: group=${groupId} sequence=${String(rawSequence ?? 0)}`, + ); + } + return sequence; +} + const MEMBER_LIST_TTL_MS = 60_000; export class ContactsApi { @@ -387,25 +404,107 @@ export class ContactsApi { return info; } - async fetchGroupRequests(filtered = false): Promise { - const resp = await FetchGroupRequests.invoke(this.ctx, { filtered }); + async fetchGroupRequests( + filtered = false, + count = 50, + cursor = 0n, + ): Promise { + const resp = await FetchGroupRequests.invoke(this.ctx, { filtered, count, cursor }); const requests: GroupRequestInfo[] = []; for (const raw of resp.requests ?? []) { + const groupId = raw.group?.groupUin ?? 0; + const targetUin = raw.target?.uin ?? 0; + const invitorUin = raw.invitor?.uin ?? 0; + const operatorUin = raw.operatorUser?.uin ?? 0; + const notifyType = raw.eventType ?? 0; + const operationType = groupRequestOperationType(notifyType); + const sequence = normalizeGroupRequestSequence(raw.sequence, groupId); + if (operationType === null) { + log.warn( + 'unsupported group-request notification type: group=%d sequence=%s type=%d', + groupId, + String(raw.sequence ?? 0n), + notifyType, + ); + } requests.push({ - groupId: raw.group?.groupUin ?? 0, + groupId, groupName: raw.group?.groupName ?? '', - targetUid: raw.target?.uid ?? '', - targetUin: 0, + targetUid: this.ctx.identity.findUidByUin(targetUin, groupId) + ?? this.ctx.identity.findUidByUin(targetUin) + ?? '', + targetUin, targetName: raw.target?.name ?? '', - invitorUid: raw.invitor?.uid ?? '', - invitorUin: 0, + invitorUid: this.ctx.identity.findUidByUin(invitorUin, groupId) + ?? this.ctx.identity.findUidByUin(invitorUin) + ?? '', + invitorUin, invitorName: raw.invitor?.name ?? '', - operatorUid: raw.operatorUser?.uid ?? '', - operatorUin: 0, + operatorUid: this.ctx.identity.findUidByUin(operatorUin, groupId) + ?? this.ctx.identity.findUidByUin(operatorUin) + ?? '', + operatorUin, operatorName: raw.operatorUser?.name ?? '', - sequence: Number(raw.sequence ?? 0), + sequence, state: raw.state ?? 0, - eventType: raw.eventType ?? 0, + notifyType, + eventType: operationType ?? 0, + comment: raw.comment ?? '', + filtered, + }); + } + this.ctx.identity.rememberGroupRequests(requests); + return requests; + } + + /** UID-form request list retained for correlating incoming UID-only pushes. + * Explicit list/actions use fetchGroupRequests(), which matches QQ's native + * numeric-account path and does not need profile lookups. */ + async fetchGroupRequestsByUid( + filtered = false, + count = 50, + cursor = 0n, + ): Promise { + const resp = await FetchGroupRequestsByUid.invoke(this.ctx, { filtered, count, cursor }); + const requests: GroupRequestInfo[] = []; + for (const raw of resp.requests ?? []) { + const groupId = raw.group?.groupUin ?? 0; + const targetUid = raw.target?.uid ?? ''; + const invitorUid = raw.invitor?.uid ?? ''; + const operatorUid = raw.operatorUser?.uid ?? ''; + const notifyType = raw.eventType ?? 0; + const operationType = groupRequestOperationType(notifyType); + const sequence = normalizeGroupRequestSequence(raw.sequence, groupId); + if (operationType === null) { + log.warn( + 'unsupported group-request notification type: group=%d sequence=%s type=%d', + groupId, + String(raw.sequence ?? 0n), + notifyType, + ); + } + requests.push({ + groupId, + groupName: raw.group?.groupName ?? '', + targetUid, + targetUin: this.ctx.identity.findUinByUid(targetUid, groupId) + ?? this.ctx.identity.findUinByUid(targetUid) + ?? 0, + targetName: raw.target?.name ?? '', + invitorUid, + invitorUin: this.ctx.identity.findUinByUid(invitorUid, groupId) + ?? this.ctx.identity.findUinByUid(invitorUid) + ?? 0, + invitorName: raw.invitor?.name ?? '', + operatorUid, + operatorUin: this.ctx.identity.findUinByUid(operatorUid, groupId) + ?? this.ctx.identity.findUinByUid(operatorUid) + ?? 0, + operatorName: raw.operatorUser?.name ?? '', + sequence, + state: raw.state ?? 0, + notifyType, + eventType: operationType ?? 0, comment: raw.comment ?? '', filtered, }); diff --git a/packages/core/src/bridge/bridge.ts b/packages/core/src/bridge/bridge.ts index 26a72ad0..df96d272 100644 --- a/packages/core/src/bridge/bridge.ts +++ b/packages/core/src/bridge/bridge.ts @@ -70,8 +70,8 @@ export class Bridge implements BridgeInterface { }, resolveGroupJoinRequest: async (groupId, uid, subType) => { const [main, filtered] = await Promise.allSettled([ - this.apis.contacts.fetchGroupRequests(false), - this.apis.contacts.fetchGroupRequests(true), + this.apis.contacts.fetchGroupRequestsByUid(false), + this.apis.contacts.fetchGroupRequestsByUid(true), ]); if (main.status === 'rejected') { log.warn('group-request enrichment main inbox failed: group=%d uid=%s err=%s', diff --git a/packages/core/tests/actions/contacts.test.ts b/packages/core/tests/actions/contacts.test.ts index 92a7fec5..c7b3e396 100644 --- a/packages/core/tests/actions/contacts.test.ts +++ b/packages/core/tests/actions/contacts.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it, vi } from 'vitest'; import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; +import type { pb, pb_repeated, uint_32, uint_64 } from '@snowluma/proton'; import type { SendPacketResult } from '@snowluma/common/packet-sender'; import type { OidbBase, @@ -20,6 +21,36 @@ import type { import { ContactsApi } from '../../src/bridge/apis/contacts'; +interface ObservedGroupRequestUserByUin { + uin?: pb<1, uint_32>; + name?: pb<2, string>; +} + +interface ObservedGroupRequestUserByUid { + uid?: pb<1, string>; + name?: pb<2, string>; +} + +interface ObservedGroupRequestGroup { + groupUin?: pb<1, uint_32>; + groupName?: pb<2, string>; +} + +interface ObservedGroupRequest { + sequence?: pb<1, uint_64>; + eventType?: pb<2, uint_32>; + state?: pb<3, uint_32>; + group?: pb<4, ObservedGroupRequestGroup>; + target?: pb<5, TUser>; + invitor?: pb<6, TUser>; + operatorUser?: pb<7, TUser>; + comment?: pb<10, string>; +} + +interface ObservedGroupRequestResponse { + requests?: pb_repeated<1, ObservedGroupRequest>; +} + function friend( uin: number, categoryId: number, @@ -112,6 +143,34 @@ function groupDetailPacket(body: OidbSvcTrpcTcp0x88D_0Response): SendPacketResul }; } +function groupRequestPacketByUin( + body: ObservedGroupRequestResponse, +): SendPacketResult { + return { + success: true, + gotResponse: true, + errorCode: 0, + errorMessage: '', + responseData: Buffer.from( + protobuf_encode>>({ body }), + ), + }; +} + +function groupRequestPacketByUid( + body: ObservedGroupRequestResponse, +): SendPacketResult { + return { + success: true, + gotResponse: true, + errorCode: 0, + errorMessage: '', + responseData: Buffer.from( + protobuf_encode>>({ body }), + ), + }; +} + function apiForPages(pages: OidbSvcTrpcTcp0xFD4_1Response[]) { let index = 0; const sendRawPacket = vi.fn(async ( @@ -212,6 +271,75 @@ describe('apis/contacts / group roster', () => { }); }); +describe('apis/contacts / group requests', () => { + it('maps the native numeric-account response into directly actionable requests', async () => { + const rememberGroupRequests = vi.fn(); + const findUidByUin = vi.fn((uin: number) => uin === 1_234_567_890 ? 'cached_target_uid' : null); + const sendRawPacket = vi.fn(async () => groupRequestPacketByUin({ + requests: [{ + sequence: 1_785_525_232_784_291n, + eventType: 7, + state: 1, + group: { groupUin: 1_095_186_374, groupName: 'group' }, + target: { uin: 1_234_567_890, name: 'requester' }, + invitor: { uin: 2_345_678_901, name: 'inviter' }, + operatorUser: { uin: 3_456_789_012, name: 'operator' }, + comment: 'please', + }], + })); + const api = new ContactsApi({ + sendRawPacket, + identity: { findUidByUin, rememberGroupRequests }, + } as any); + + const requests = await api.fetchGroupRequests(false); + + expect(requests).toEqual([expect.objectContaining({ + groupId: 1_095_186_374, + targetUid: 'cached_target_uid', + targetUin: 1_234_567_890, + invitorUin: 2_345_678_901, + operatorUin: 3_456_789_012, + sequence: 1_785_525_232_784_291, + notifyType: 7, + eventType: 1, + filtered: false, + })]); + expect(rememberGroupRequests).toHaveBeenCalledWith(requests); + }); + + it('retains the UID-form response for correlating real-time request pushes', async () => { + const rememberGroupRequests = vi.fn(); + const findUinByUid = vi.fn((uid: string) => uid === 'target_uid' ? 1_234_567_890 : null); + const sendRawPacket = vi.fn(async () => groupRequestPacketByUid({ + requests: [{ + sequence: 42n, + eventType: 7, + state: 1, + group: { groupUin: 999, groupName: 'group' }, + target: { uid: 'target_uid', name: 'requester' }, + invitor: { uid: 'inviter_uid', name: 'inviter' }, + operatorUser: { uid: 'operator_uid', name: 'operator' }, + }], + })); + const api = new ContactsApi({ + sendRawPacket, + identity: { findUinByUid, rememberGroupRequests }, + } as any); + + const requests = await api.fetchGroupRequestsByUid(true); + + expect(requests).toEqual([expect.objectContaining({ + targetUid: 'target_uid', + targetUin: 1_234_567_890, + invitorUid: 'inviter_uid', + operatorUid: 'operator_uid', + filtered: true, + })]); + expect(rememberGroupRequests).toHaveBeenCalledWith(requests); + }); +}); + describe('apis/contacts / categorized friend roster', () => { it('keeps fetchFriendList flat while traversing cookie pages', async () => { const cookie = Uint8Array.from([0x01]); diff --git a/packages/proto-defs/src/oidb-actions/base.ts b/packages/proto-defs/src/oidb-actions/base.ts index 56f2ed3f..a0163c4f 100644 --- a/packages/proto-defs/src/oidb-actions/base.ts +++ b/packages/proto-defs/src/oidb-actions/base.ts @@ -217,7 +217,7 @@ export interface OidbLike { } export interface OidbGroupRequestList { count?: pb<1, uint_32>; - field2?: pb<2, uint_32>; + field2?: pb<2, uint_64>; } export interface OidbUserInfoKey { key?: pb<1, uint_32>; diff --git a/packages/proto-defs/src/oidb.ts b/packages/proto-defs/src/oidb.ts index fc04d734..f2065315 100644 --- a/packages/proto-defs/src/oidb.ts +++ b/packages/proto-defs/src/oidb.ts @@ -184,7 +184,7 @@ export interface OidbRobotUinRangeResponse { robotConfig?: pb<5, OidbRobotUinRangeConfig>; } -// OIDB.0x10C0 Group Request +// OIDB.0x10C0 Group Request — UID-form response (envelope reserved=0). export interface OidbSvcTrpcTcp0x10C0ResponseUser { uid?: pb<1, string>; name?: pb<2, string>; @@ -215,3 +215,33 @@ export interface OidbSvcTrpcTcp0x10C0Response { field5?: pb<5, uint_64>; field6?: pb<6, uint_32>; } + +// The native UIN-form request (envelope reserved=1) uses the same response +// tags, but user field 1 changes wire type from string to uint32. Keep a +// separate schema: decoding both forms through one interface would silently +// discard every numeric account identifier as a mismatched wire type. +export interface OidbSvcTrpcTcp0x10C0ResponseUserByUin { + uin?: pb<1, uint_32>; + name?: pb<2, string>; +} + +export interface OidbSvcTrpcTcp0x10C0ResponseRequestByUin { + sequence?: pb<1, uint_64>; + eventType?: pb<2, uint_32>; + state?: pb<3, uint_32>; + group?: pb<4, OidbSvcTrpcTcp0x10C0ResponseGroup>; + target?: pb<5, OidbSvcTrpcTcp0x10C0ResponseUserByUin>; + invitor?: pb<6, OidbSvcTrpcTcp0x10C0ResponseUserByUin>; + operatorUser?: pb<7, OidbSvcTrpcTcp0x10C0ResponseUserByUin>; + field9?: pb<9, string>; + comment?: pb<10, string>; +} + +export interface OidbSvcTrpcTcp0x10C0ResponseByUin { + requests?: pb_repeated<1, OidbSvcTrpcTcp0x10C0ResponseRequestByUin>; + field2?: pb<2, uint_64>; + newLatestSeq?: pb<3, uint_64>; + field4?: pb<4, uint_32>; + field5?: pb<5, uint_64>; + field6?: pb<6, uint_32>; +} diff --git a/packages/protocol/src/oidb-services/contacts/fetch-group-requests.ts b/packages/protocol/src/oidb-services/contacts/fetch-group-requests.ts index 3126f688..8887f84b 100644 --- a/packages/protocol/src/oidb-services/contacts/fetch-group-requests.ts +++ b/packages/protocol/src/oidb-services/contacts/fetch-group-requests.ts @@ -1,30 +1,86 @@ // 0x10C0 — fetch pending group-add requests. // subCommand 1 = main inbox, 2 = filtered (low-priority) inbox // -// Returns the wire shape verbatim — the facade does the GroupRequestInfo -// mapping because it also needs to thread the `filtered` flag onto -// each entry, which the wire doesn't carry. +// Current QQ uses the UIN-form envelope for its native list path. The server +// changes user field 1 from a UID string to a numeric UIN when that envelope +// bit changes, so the two forms deliberately have separate decoders below. +// The UID form remains necessary for correlating UID-only real-time pushes. import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; -import type { OidbBase, OidbSvcTrpcTcp0x10C0Response } from '@snowluma/proto-defs/oidb'; +import type { + OidbBase, + OidbSvcTrpcTcp0x10C0Response, + OidbSvcTrpcTcp0x10C0ResponseByUin, +} from '@snowluma/proto-defs/oidb'; import type { OidbGroupRequestList } from '@snowluma/proto-defs/oidb-actions/base'; import { invokeOidb, type OidbSender } from '../../oidb-service'; +// Current QQ's EncodeOperateSysNotify maps the high-level list notification +// type to the discriminator sent by 0x10C8. This table was read directly from +// the current Linux client; keeping the distinction prevents list type 7 +// (join request) from being incorrectly sent back as operation type 7. +const GROUP_REQUEST_OPERATION_TYPE = new Map([ + [0, 0], [1, 2], [2, 10], [3, 11], [4, 12], [5, 22], + [6, 35], [7, 1], [8, 3], [9, 6], [10, 7], [11, 13], + [12, 15], [13, 16], [14, 17], [15, 19], [16, 8], [17, 100], +]); + +export function groupRequestOperationType(notifyType: number): number | null { + return GROUP_REQUEST_OPERATION_TYPE.get(notifyType) ?? null; +} + export namespace FetchGroupRequests { export const command = 0x10C0; + export const uinForm = true; export interface Params { /** false → subCmd 1 (main inbox), true → subCmd 2 (filtered). */ filtered: boolean; + /** Maximum records in this screen. QQ's own default is 50. */ + count?: number; + /** Cursor returned by response field 2; zero starts at the newest screen. */ + cursor?: bigint; } export type Deps = OidbSender; export const resolveSubCommand = (p: Params): number => p.filtered ? 2 : 1; - export const serialize = (_ctx: Deps, _: Params): OidbGroupRequestList => ({ - count: 20, - field2: 0, + export const serialize = (_ctx: Deps, p: Params): OidbGroupRequestList => ({ + count: p.count ?? 50, + field2: p.cursor ?? 0n, + }); + + export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0x10C0ResponseByUin): OidbSvcTrpcTcp0x10C0ResponseByUin => body; + + export const encode = (env: OidbBase): Uint8Array => + protobuf_encode>(env); + + export const decode = (bytes: Uint8Array): OidbBase => + protobuf_decode>(bytes); + + export const invoke = (deps: Deps, params: Params): Promise => + invokeOidb(deps, FetchGroupRequests, params); +} + +/** UID-form compatibility path used only when an incoming push supplies UID + * but no UIN. It intentionally leaves the envelope's reserved field unset. */ +export namespace FetchGroupRequestsByUid { + export const command = 0x10C0; + + export interface Params { + filtered: boolean; + count?: number; + cursor?: bigint; + } + + export type Deps = OidbSender; + + export const resolveSubCommand = (p: Params): number => p.filtered ? 2 : 1; + + export const serialize = (_ctx: Deps, p: Params): OidbGroupRequestList => ({ + count: p.count ?? 50, + field2: p.cursor ?? 0n, }); export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0x10C0Response): OidbSvcTrpcTcp0x10C0Response => body; @@ -36,5 +92,5 @@ export namespace FetchGroupRequests { protobuf_decode>(bytes); export const invoke = (deps: Deps, params: Params): Promise => - invokeOidb(deps, FetchGroupRequests, params); + invokeOidb(deps, FetchGroupRequestsByUid, params); } diff --git a/packages/protocol/src/qq-info.ts b/packages/protocol/src/qq-info.ts index 579580c9..3e944d0e 100644 --- a/packages/protocol/src/qq-info.ts +++ b/packages/protocol/src/qq-info.ts @@ -75,6 +75,9 @@ export interface GroupRequestInfo { operatorName: string; sequence: number; state: number; + /** High-level notification type returned by the request list. */ + notifyType?: number; + /** 0x10C8 operation discriminator derived from notifyType. */ eventType: number; comment: string; filtered: boolean; diff --git a/packages/protocol/tests/oidb-services/contacts/fetch-group-requests.test.ts b/packages/protocol/tests/oidb-services/contacts/fetch-group-requests.test.ts index d45232e7..74ca57ea 100644 --- a/packages/protocol/tests/oidb-services/contacts/fetch-group-requests.test.ts +++ b/packages/protocol/tests/oidb-services/contacts/fetch-group-requests.test.ts @@ -1,10 +1,41 @@ import { describe, expect, it, vi } from 'vitest'; -import { protobuf_decode } from '@snowluma/proton'; +import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; +import type { pb, pb_repeated, uint_32, uint_64 } from '@snowluma/proton'; import type { OidbBase } from '@snowluma/proto-defs/oidb'; import type { OidbGroupRequestList } from '@snowluma/proto-defs/oidb-actions/base'; import type { SendPacketResult } from '@snowluma/common/packet-sender'; -import { FetchGroupRequests } from '../../../src/oidb-services/contacts/fetch-group-requests'; +import { + FetchGroupRequests, + FetchGroupRequestsByUid, + groupRequestOperationType, +} from '../../../src/oidb-services/contacts/fetch-group-requests'; + +interface ObservedGroupRequestUserByUin { + uin?: pb<1, uint_32>; + name?: pb<2, string>; +} + +interface ObservedGroupRequestGroup { + groupUin?: pb<1, uint_32>; + groupName?: pb<2, string>; +} + +interface ObservedGroupRequestByUin { + sequence?: pb<1, uint_64>; + eventType?: pb<2, uint_32>; + state?: pb<3, uint_32>; + group?: pb<4, ObservedGroupRequestGroup>; + target?: pb<5, ObservedGroupRequestUserByUin>; + invitor?: pb<6, ObservedGroupRequestUserByUin>; + operatorUser?: pb<7, ObservedGroupRequestUserByUin>; + comment?: pb<10, string>; +} + +interface ObservedGroupRequestResponseByUin { + requests?: pb_repeated<1, ObservedGroupRequestByUin>; + cursor?: pb<2, uint_64>; +} function makeSender() { const r: SendPacketResult = { success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData: Buffer.alloc(0) }; @@ -12,8 +43,17 @@ function makeSender() { } describe('FetchGroupRequests namespace', () => { + it('maps native list notification types to 0x10C8 operation types', () => { + expect(groupRequestOperationType(1)).toBe(2); + expect(groupRequestOperationType(7)).toBe(1); + expect(groupRequestOperationType(17)).toBe(100); + expect(groupRequestOperationType(99)).toBeNull(); + }); + it('declares 0x10C0', () => { expect(FetchGroupRequests.command).toBe(0x10C0); + expect(FetchGroupRequests.uinForm).toBe(true); + expect((FetchGroupRequestsByUid as { uinForm?: boolean }).uinForm).toBeUndefined(); }); describe('resolveSubCommand', () => { @@ -26,9 +66,18 @@ describe('FetchGroupRequests namespace', () => { }); describe('serialize', () => { - it('always sends count=20 / field2=0', () => { - expect(FetchGroupRequests.serialize({} as any, { filtered: false })).toEqual({ count: 20, field2: 0 }); - expect(FetchGroupRequests.serialize({} as any, { filtered: true })).toEqual({ count: 20, field2: 0 }); + it('defaults to one native 50-item screen at cursor zero', () => { + expect(FetchGroupRequests.serialize({} as any, { filtered: false })).toEqual({ count: 50, field2: 0n }); + expect(FetchGroupRequestsByUid.serialize({} as any, { filtered: true })).toEqual({ count: 50, field2: 0n }); + }); + + it('preserves a caller-provided count and 64-bit cursor', () => { + const cursor = 1_785_406_628_779_279n; + expect(FetchGroupRequests.serialize({} as any, { + filtered: false, + count: 80, + cursor, + })).toEqual({ count: 80, field2: cursor }); }); }); @@ -45,12 +94,60 @@ describe('FetchGroupRequests namespace', () => { expect(sender.sendRawPacket.mock.calls[0]![0]).toBe('OidbSvcTrpcTcp.0x10c0_2'); }); - it('encodes envelope body with count=20', async () => { + it('encodes the native envelope and requested screen', async () => { const sender = makeSender(); - await FetchGroupRequests.invoke(sender, { filtered: false }); + await FetchGroupRequests.invoke(sender, { + filtered: false, + count: 80, + cursor: 1_785_406_628_779_279n, + }); const [, bytes] = sender.sendRawPacket.mock.calls[0]!; const env = protobuf_decode>(bytes); - expect(env.body?.count).toBe(20); + expect(env.reserved).toBe(1); + expect(env.body).toEqual({ count: 80, field2: 1_785_406_628_779_279n }); + }); + + it('decodes numeric account identifiers from the native response', async () => { + const responseData = Buffer.from(protobuf_encode>({ + body: { + requests: [{ + sequence: 1_785_525_232_784_291n, + eventType: 7, + state: 1, + group: { groupUin: 1_095_186_374, groupName: 'group' }, + target: { uin: 1_234_567_890, name: 'requester' }, + invitor: { uin: 2_345_678_901, name: 'inviter' }, + operatorUser: { uin: 3_456_789_012, name: 'operator' }, + comment: 'please', + }], + cursor: 1_785_406_628_779_279n, + }, + })); + const result: SendPacketResult = { + success: true, + gotResponse: true, + errorCode: 0, + errorMessage: '', + responseData, + }; + const sender = { sendRawPacket: vi.fn(async () => result) }; + + const response = await FetchGroupRequests.invoke(sender, { filtered: false }); + + expect(response.requests?.[0]).toMatchObject({ + target: { uin: 1_234_567_890, name: 'requester' }, + invitor: { uin: 2_345_678_901, name: 'inviter' }, + operatorUser: { uin: 3_456_789_012, name: 'operator' }, + }); + expect(response.field2).toBe(1_785_406_628_779_279n); + }); + + it('keeps the UID response path on the non-native envelope', async () => { + const sender = makeSender(); + await FetchGroupRequestsByUid.invoke(sender, { filtered: false }); + const [, bytes] = sender.sendRawPacket.mock.calls[0]!; + const env = protobuf_decode>(bytes); + expect(env.reserved ?? 0).toBe(0); }); }); });