fix(protocol): restore filtered friend request approvals

Correct approval handling for filtered friend requests and preserve clear failures when an account cannot be resolved or the request is rejected.

Add regression coverage for separate account identities, approval errors, and existing list and rejection behavior.

Fixes #460
This commit is contained in:
DrSmoothl committed 2026-09-26 16:59:52 +08:00
1 parent 7a07119ee9
commit 797a4d754c
8 files changed
+164 -80

No files matched your search

@@ -1,28 +1,31 @@
// 0xd69_0 — approvalDoubtBuddyReq: approve a doubtful friend-add request
// (可能认识的人). RE'd from QQNT doubt_codec.cc EncodeRequest sub_3F3EC90:
// {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). The reject/decline path is a separate
// cmd (delDoubtBuddyReq) — see sibling reject-doubt-buddy-req.ts.
// Approve an existing filtered friend request.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbDoubtApprovalReq } from '@snowluma/proto-defs/oidb-actions/doubt-buddy';
import type { BridgeContext } from '../../bridge-context';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import { resolveSelfUid } from '../../self-uid';
export namespace ApproveDoubtBuddyReq {
export const command = 0xD69;
export const command = 0xD72;
export const subCommand = 0;
export const uinForm = true;
export const uinForm = false;
export interface Params { uid: string }
export type Deps = OidbSender;
export type Deps = OidbSender & Pick<BridgeContext, 'identity' | 'resolveUserUid'>;
export const serialize = (_ctx: Deps, p: Params): OidbDoubtApprovalReq => ({
uid: p.uid,
targetUid: p.uid,
});
export const serialize = async (ctx: Deps, p: Params): Promise<OidbDoubtApprovalReq> => {
if (!p.uid.trim()) throw new Error('cannot approve doubt request: applicant uid is unavailable');
const selfUid = await resolveSelfUid(ctx);
if (!selfUid.trim()) throw new Error('cannot approve doubt request: self uid is unavailable');
return {
selfUid,
targetUid: p.uid,
field3: 0,
field4: '',
};
};
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
@@ -2,7 +2,7 @@
// 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.
// uses 1). Rejection shares the listing command, not the approval command.
// uin-form OIDB (envelope reserved=1).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';