feat(onebot): TierB ③ followup — doubt-buddy reject path (delDoubtBuddyReq)

set_doubt_friends_add_request with approve:false now rejects/declines via
delDoubtBuddyReq instead of erroring. RE'd from QQNT wrapper.linux.node
(DoubtBuddyDelWorker ctor sub_3F3F320 → OIDB 0xd69_0; EncodeRequest
sub_3F3E860 body {1: varint const 3 (op discriminator; get uses 1),
3:{1: string uid}}, uid from kernel attr 21001). uin-form (reserved=1).
Adversarially IDA-verified; byte-oracle locks the tags. Split out as its
own commit because the approve-only 0xd69_0 work was already pushed.
This commit is contained in:
DrSmoothl committed 2026-06-18 22:18:08 +08:00
1 parent 43cd4a0b99
commit 7ea1ffb497
8 files changed
+114 -15

No files matched your search

+4
View File
@@ -95,6 +95,10 @@
"types": "./src/oidb-services/friend/approve-doubt-buddy-req.ts",
"default": "./src/oidb-services/friend/approve-doubt-buddy-req.ts"
},
"./oidb-services/friend/reject-doubt-buddy-req": {
"types": "./src/oidb-services/friend/reject-doubt-buddy-req.ts",
"default": "./src/oidb-services/friend/reject-doubt-buddy-req.ts"
},
"./oidb-services/contacts/get-buddy-recommend-ark": {
"types": "./src/oidb-services/contacts/get-buddy-recommend-ark.ts",
"default": "./src/oidb-services/contacts/get-buddy-recommend-ark.ts"
@@ -3,8 +3,8 @@
// {1:uid, 2:uid, [3:u32], [4:str]} — tags 3/4 emitted only when present, and
// NapCat passes empty str1/str2, so the approve flow is just {1:uid, 2:uid}.
// Same OIDB cmd as the getter; the server discriminates by body shape.
// uin-form OIDB (envelope reserved=1). NapCat only supports approve (no
// reject — rejection would be a separate delDoubtBuddyReq cmd, not RE'd here).
// uin-form OIDB (envelope reserved=1). The reject/decline path is a separate
// cmd (delDoubtBuddyReq) — see sibling reject-doubt-buddy-req.ts.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
@@ -0,0 +1,36 @@
// 0xd69_0 — delDoubtBuddyReq: delete/reject (decline) a doubtful friend-add
// request. RE'd from QQNT doubt_buddy_del_worker.cc (worker ctor sub_3F3F320
// → cmd 0xd69 sub 0; EncodeRequest sub_3F3E860 writes {1: const 3, 3:{1:uid}}).
// The top-level tag-1 constant 3 is the op discriminator (getDoubtBuddyReq
// uses 1). Same OIDB cmd as get/approval; the server routes by body shape.
// uin-form OIDB (envelope reserved=1).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbDoubtDelReq } from '@snowluma/proto-defs/oidb-actions/doubt-buddy';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace RejectDoubtBuddyReq {
export const command = 0xD69;
export const subCommand = 0;
export const uinForm = true;
export interface Params { uid: string }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbDoubtDelReq => ({
field1: 3,
inner: { uid: p.uid },
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbDoubtDelReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbDoubtDelReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, RejectDoubtBuddyReq, params);
}
@@ -0,0 +1,38 @@
import { describe, expect, it, vi } from 'vitest';
import { protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { SendPacketResult } from '@snowluma/common/packet-sender';
import { RejectDoubtBuddyReq } from '../../../src/oidb-services/friend/reject-doubt-buddy-req';
import { env, v, s, m } from '../_pb-oracle';
function makeSender() {
const respEnv: OidbBase<OidbEmpty> = { command: 0xD69, subCommand: 0, body: {} };
const r: SendPacketResult = {
success: true, gotResponse: true, errorCode: 0, errorMessage: '',
responseData: Buffer.from(protobuf_encode<OidbBase<OidbEmpty>>(respEnv)),
};
return { sendRawPacket: vi.fn(async () => r) };
}
describe('RejectDoubtBuddyReq namespace', () => {
it('declares command 0xD69 sub 0, uin form', () => {
expect(RejectDoubtBuddyReq.command).toBe(0xD69);
expect(RejectDoubtBuddyReq.subCommand).toBe(0);
expect(RejectDoubtBuddyReq.uinForm).toBe(true);
});
it('serializes {1: const 3 (op discriminator), 3: {1: uid}}', () => {
expect(RejectDoubtBuddyReq.serialize({} as any, { uid: 'u_x' })).toEqual({ field1: 3, inner: { uid: 'u_x' } });
});
it('byte-oracle: routes to 0xd69_0 and locks req tags {1:const3, 3:{1:uid}}', async () => {
const sender = makeSender();
await RejectDoubtBuddyReq.invoke(sender, { uid: 'u_abc' });
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
expect(cmd).toBe('OidbSvcTrpcTcp.0xd69_0');
const inner = [...s(1, 'u_abc')];
const body = [...v(1, 3), ...m(3, inner)];
expect(Buffer.from(bytes).toString('hex')).toBe(env(0xD69, 0, body, true));
});
});