Skip to content

Commit

Permalink
feat: 친구 요청을 받은 사람이 요청을 삭제하는 로직 추가 (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeong-hyeok committed Sep 30, 2023
1 parent 45598c9 commit 956e3cf
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public void saveFriendRequest(String email, Long friendId) {
public void deleteFriendRequest(String email, Long friendId) {
Member member = memberRepository.findByEmail(email).orElseThrow(() -> new BusinessException(ErrorCode.MEMBER_NOT_FOUND));
Member friend = memberRepository.findById(friendId).orElseThrow(() -> new BusinessException(ErrorCode.MEMBER_NOT_FOUND));
FriendRequest friendRequest = friendRequestRepository.findByFromMemberAndToMember(member, friend).orElseThrow(() -> new BusinessException(ErrorCode.FRIEND_REQUEST_NOT_FOUND));
FriendRequest friendRequest = friendRequestRepository.findByFromMemberAndToMember(member, friend).orElse(null);
if (friendRequest == null) {
friendRequest = friendRequestRepository.findByFromMemberAndToMember(friend, member).orElseThrow(() -> new BusinessException(ErrorCode.FRIEND_REQUEST_NOT_FOUND));
}
friendRequestRepository.delete(friendRequest);
}

Expand Down

0 comments on commit 956e3cf

Please sign in to comment.