Skip to content

Commit

Permalink
[COZY-328] fix: 방 참여 요청시 EXITED 상태인 경우 재사용 (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
suuu0719 authored Dec 2, 2024
1 parent 2acf136 commit 180045a
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,22 @@ public void requestToJoin(Long roomId, Long memberId) {
throw new GeneralException(ErrorStatus._ROOM_ALREADY_EXISTS);
}

Optional<Mate> existingMate = mateRepository.findByRoomIdAndMemberIdAndNotEntryStatus(
roomId, memberId, EntryStatus.EXITED);
Optional<Mate> existingMate = mateRepository.findByRoomIdAndMemberId(room.getId(), memberId);
checkEntryStatus(existingMate);

if (room.getNumOfArrival() >= room.getMaxMateNum()) {
throw new GeneralException(ErrorStatus._ROOM_FULL);
}

Mate mate = MateConverter.toPending(room, member, false);
mateRepository.save(mate);
if (existingMate.isPresent()) {
Mate mate = existingMate.get();
mate.setEntryStatus(EntryStatus.PENDING);
mate.setNotExit();
mateRepository.save(mate);
} else {
Mate mate = MateConverter.toPending(room, member, false);
mateRepository.save(mate);
}

// 푸시 알림 코드
Mate managerMate = mateRepository.findFetchByRoomAndIsRoomManager(room, true).orElseThrow(
Expand Down

0 comments on commit 180045a

Please sign in to comment.