From 6ec368f4b5a84fcde100c5dfa216c3df4e766520 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Fri, 21 Aug 2026 18:26:02 +0800 Subject: [PATCH] fix(onebot): restore doubt-request account ids from the native list get_doubt_friends_add_request was rereading the uid as a number, so uid came back empty and user_id was wrong. Keep the uid string and the account number as separate fields. Fixes #410 --- .../friend/get-doubt-buddy-req.ts | 32 +++---------------- .../friend/get-doubt-buddy-req.test.ts | 22 +++++++++++++ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/protocol/src/oidb-services/friend/get-doubt-buddy-req.ts b/packages/protocol/src/oidb-services/friend/get-doubt-buddy-req.ts index f5c0d3d7..d8faac92 100644 --- a/packages/protocol/src/oidb-services/friend/get-doubt-buddy-req.ts +++ b/packages/protocol/src/oidb-services/friend/get-doubt-buddy-req.ts @@ -1,27 +1,17 @@ // 0xd69_0 — getDoubtBuddyReq: list the "doubtful" friend-add requests // (可能认识的人 / 被过滤的好友申请). RE'd from QQNT doubt_codec.cc. // Request {1:1, 2:{1:num, 2:uk}} (reqId is NOT on the wire). Response body -// holds a repeated item list; we surface the fields NapCat exposes. -// READ-only: the string field names (nick/source/msg) are MEDIUM confidence -// (generic serializer), so a mislabel is cosmetic, never a wire/ban risk. -// uid (tag1) and reqTime (tag9) are HIGH confidence. +// holds a repeated item list. DecodePullDoubtReq maps uid as a string and +// the account number as a separate integer field; do not reread the uid +// field as a number. String names (nick/source/msg) are MEDIUM confidence. 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 { OidbDoubtGetReq, OidbDoubtGetResp, } from '@snowluma/proto-defs/oidb-actions/doubt-buddy'; import { invokeOidb, type OidbSender } from '../../oidb-service'; -interface OidbDoubtItemAccountOnTag1 { - uin?: pb<1, uint_64>; -} -interface OidbDoubtGetRespAccountOnTag1 { - status?: pb<1, uint_32>; - body?: pb<2, { list?: pb_repeated<1, OidbDoubtItemAccountOnTag1> }>; -} - export interface DoubtBuddyRequest { [key: string]: import('@snowluma/common/json').JsonValue; /** Opaque uid — pass back as `flag` to set_doubt_friends_add_request. */ @@ -63,20 +53,8 @@ export namespace GetDoubtBuddyReq { export const encode = (env: OidbBase): Uint8Array => protobuf_encode>(env); - export const decode = (bytes: Uint8Array): OidbBase => { - const decoded = protobuf_decode>(bytes); - const numeric = protobuf_decode>(bytes); - const items = decoded.body?.body?.list ?? []; - const numericItems = numeric.body?.body?.list ?? []; - for (let i = 0; i < items.length; i++) { - const item = items[i]; - if (!item) continue; - if ((item.uin ?? 0n) === 0n && numericItems[i]?.uin) { - item.uin = numericItems[i]!.uin; - } - } - return decoded; - }; + export const decode = (bytes: Uint8Array): OidbBase => + protobuf_decode>(bytes); export const invoke = (deps: Deps, params: Params): Promise => invokeOidb(deps, GetDoubtBuddyReq, params); diff --git a/packages/protocol/tests/oidb-services/friend/get-doubt-buddy-req.test.ts b/packages/protocol/tests/oidb-services/friend/get-doubt-buddy-req.test.ts index 4033a4bf..9028d46d 100644 --- a/packages/protocol/tests/oidb-services/friend/get-doubt-buddy-req.test.ts +++ b/packages/protocol/tests/oidb-services/friend/get-doubt-buddy-req.test.ts @@ -59,4 +59,26 @@ describe('GetDoubtBuddyReq namespace', () => { it('deserialize returns [] when the body has no list', () => { expect(GetDoubtBuddyReq.deserialize({} as any, { status: 1 })).toEqual([]); }); + + it('keeps the uid string and does not reread it as the account number', async () => { + const respEnv: OidbBase = { + command: 0xD69, subCommand: 0, + body: { status: 1, body: { list: [ + { uid: 'u_alice', nick: 'Alice', msg: 'hi', source: 'QQ号查找', reason: 'caution' }, + ] } }, + }; + const sender = { + sendRawPacket: vi.fn(async () => ({ + success: true, gotResponse: true, errorCode: 0, errorMessage: '', + responseData: Buffer.from(protobuf_encode>(respEnv)), + })), + }; + const list = await GetDoubtBuddyReq.invoke(sender, { count: 10 }); + expect(list).toEqual([ + { + uid: 'u_alice', user_id: 0, nick: 'Alice', source: 'QQ号查找', + reason: 'caution', msg: 'hi', group_code: '', reqTime: 0, + }, + ]); + }); });