From 32afbf12d64259017e14aecf6da8d7996f1a5999 Mon Sep 17 00:00:00 2001 From: Hampus Date: Fri, 21 Aug 2026 20:31:32 +0200 Subject: [PATCH] fix(api): stop treating accounts pending deletion as already deleted (#1816) --- .../user/services/UserRelationshipService.ts | 3 +++ .../UserRelationshipStateTransitions.test.ts | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/fluxer_api/src/api/user/services/UserRelationshipService.ts b/fluxer_api/src/api/user/services/UserRelationshipService.ts index f127a0793..3b2931487 100644 --- a/fluxer_api/src/api/user/services/UserRelationshipService.ts +++ b/fluxer_api/src/api/user/services/UserRelationshipService.ts @@ -808,6 +808,9 @@ export class UserRelationshipService { if (!user) { return false; } + if (user.pendingDeletionAt !== null) { + return false; + } return (user.flags & UserFlags.DELETED) === UserFlags.DELETED; } } diff --git a/fluxer_api/src/api/user/tests/UserRelationshipStateTransitions.test.ts b/fluxer_api/src/api/user/tests/UserRelationshipStateTransitions.test.ts index 163da00b7..e15bbce1f 100644 --- a/fluxer_api/src/api/user/tests/UserRelationshipStateTransitions.test.ts +++ b/fluxer_api/src/api/user/tests/UserRelationshipStateTransitions.test.ts @@ -19,6 +19,16 @@ import { } from './RelationshipTestUtils'; import {fetchUserMe} from './UserTestUtils'; +async function markUserScheduledForDeletion(harness: ApiTestHarness, userId: string): Promise { + const pendingDeletionAt = new Date(Date.now() + 14 * 24 * 60 * 60 * 1000).toISOString(); + await createBuilder(harness, '') + .post(`/test/users/${userId}/set-pending-deletion`) + .body({pending_deletion_at: pendingDeletionAt, set_self_deleted_flag: false}) + .expect(HTTP_STATUS.OK) + .execute(); + await markUserDeleted(harness, userId); +} + async function markUserDeleted(harness: ApiTestHarness, userId: string): Promise { await createBuilder(harness, '') .patch(`/test/users/${userId}/flags`) @@ -221,6 +231,16 @@ describe('UserRelationshipStateTransitions', () => { .expect(HTTP_STATUS.BAD_REQUEST, 'FRIEND_REQUEST_BLOCKED') .execute(); }); + test('can accept a friend request from a user scheduled for deletion', async () => { + const alice = await createTestAccount(harness); + const bob = await createTestAccount(harness); + await sendFriendRequest(harness, bob.token, alice.userId); + await markUserScheduledForDeletion(harness, bob.userId); + const {json: friendship} = await acceptFriendRequest(harness, alice.token, bob.userId); + assertRelationshipType(friendship, RelationshipTypes.FRIEND); + const {json: aliceAfter} = await listRelationships(harness, alice.token); + assertRelationshipType(findRelationship(aliceAfter, bob.userId)!, RelationshipTypes.FRIEND); + }); test('cannot send friend request to user who blocked you', async () => { const alice = await createTestAccount(harness); const bob = await createTestAccount(harness);