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

+7 -8
View File
@@ -64,11 +64,8 @@ export class FriendApi {
if (userId <= 0 && uid) {
userId = this.ctx.identity.findUinByUid(uid) ?? 0;
}
// Current Linux replies often omit the account id even though the
// official decoder still reads it as a string. The approval packet
// cannot accept a raw number, so fill from the same uin→uid path
// used by ordinary friend requests. Cache-only lookup is not
// enough: filtered applicants are not friends or group members.
// Applicants need not be friends or share a group. Use Identity's
// profile lookup when the list only supplies an account number.
if (!uid && userId > 0) {
try {
uid = await this.ctx.resolveUserUid(userId);
@@ -86,9 +83,11 @@ export class FriendApi {
/** Approve a doubtful friend-add request. `uidOrFlag` is the list uid, or a digit-only account number. */
async approveDoubtRequest(uidOrFlag: string): Promise<void> {
return ApproveDoubtBuddyReq.invoke(this.ctx, {
uid: await this.resolveDoubtFlag(uidOrFlag),
});
log.trace('doubt-request approval: resolving applicant');
const uid = await this.resolveDoubtFlag(uidOrFlag);
log.trace('doubt-request approval: submitting request');
await ApproveDoubtBuddyReq.invoke(this.ctx, { uid });
log.trace('doubt-request approval: completed');
}
/** Reject (delete/decline) a doubtful friend-add request. `uidOrFlag` matches `approveDoubtRequest`. */