From c62f51750a27712c64640c5020dafbcc27488bca Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Mon, 18 May 2026 13:39:54 +0800 Subject: [PATCH] fix(oidb): drop the obsolete field 2 from OIDB 0xFE1_2 (user profile) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QQ now rejects fetchUserProfile() with: [oidb] one of uid/openid is invaild The cause: SnowLuma's request schema declared field 2 as a zero-valued uint32 (`field2: 0`) and our encoder doesn't skip 0 varints. Newer QQ NT versions reinterpret field 2 of OIDB 0xFE1_2 as `uid: string` / `openid: string`, so a varint 0 there decodes as an empty/invalid uid → server bounces the whole request. NapCat's equivalent transformer (Oidb.0XFE1_2.ts) emits only `uin` (field 1) and `key[]` (field 3) — nothing in field 2. Match that shape exactly. Effect: warmUpBridgeState's "self info via profile" fallback path now succeeds for accounts that QQ omits from the friend list, so the WebUI shows their nickname instead of leaving it blank. --- packages/core/src/bridge/bridge-contacts.ts | 3 ++- packages/core/src/bridge/proto/oidb-action.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/core/src/bridge/bridge-contacts.ts b/packages/core/src/bridge/bridge-contacts.ts index 63c2bbaa..23f537f1 100644 --- a/packages/core/src/bridge/bridge-contacts.ts +++ b/packages/core/src/bridge/bridge-contacts.ts @@ -208,9 +208,10 @@ export async function fetchGroupMemberList(bridge: Bridge, groupId: number): Pro export async function fetchUserProfile(bridge: Bridge, uin: number): Promise { const keys = [20002, 27394, 20009, 20031, 101, 103, 102, 20020, 20003, 20026, 105, 27372, 27406, 20037]; + // Only `uin` and `keys` — see OidbUserInfoRequestSchema for why + // sending field 2 makes the server reject the request. const body = { uin, - field2: 0, keys: keys.map(k => ({ key: k })), }; diff --git a/packages/core/src/bridge/proto/oidb-action.ts b/packages/core/src/bridge/proto/oidb-action.ts index b4b28a1a..ec521dff 100644 --- a/packages/core/src/bridge/proto/oidb-action.ts +++ b/packages/core/src/bridge/proto/oidb-action.ts @@ -190,10 +190,14 @@ export const OidbUserInfoKeySchema = { key: { field: 1, type: 'uint32' as const }, } satisfies ProtoSchema; +// Field 2 USED to be `field2: uint32 = 0`, but newer QQ NT versions +// reinterpret field 2 as `uid: string` / `openid: string` and reject +// the request with "one of uid/openid is invaild" when a varint 0 +// shows up there. NapCat's schema (Oidb.0XFE1_2.ts) only emits `uin` +// and `key[]`, so we match that exactly. export const OidbUserInfoRequestSchema = { - uin: { field: 1, type: 'uint32' as const }, - field2: { field: 2, type: 'uint32' as const }, - keys: { field: 3, type: 'repeated_message' as const, schema: OidbUserInfoKeySchema }, + uin: { field: 1, type: 'uint32' as const }, + keys: { field: 3, type: 'repeated_message' as const, schema: OidbUserInfoKeySchema }, } satisfies ProtoSchema; export const OidbTwoNumberSchema = {