From ea948ccadc7eace1fcace176c9c070b2a9b46f56 Mon Sep 17 00:00:00 2001 From: Kaity A Date: Sat, 24 Feb 2024 04:38:01 +0000 Subject: [PATCH] fix: delete old follow request (if exists) before creating new --- packages/backend/src/core/UserFollowingService.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index e82a7e06f..616e38d20 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -479,6 +479,12 @@ export class UserFollowingService implements OnModuleInit { if (blocking) throw new Error('blocking'); if (blocked) throw new Error('blocked'); + // Remove old follow requests before creating a new one. + await this.followRequestsRepository.delete({ + followeeId: followee.id, + followerId: follower.id, + }); + const followRequest = await this.followRequestsRepository.insert({ id: this.idService.gen(), followerId: follower.id,