Skip to content

Commit

Permalink
fix: 최대 개수의 라운지에 소속되어도 초대 수락되는 버그 해결 #261
Browse files Browse the repository at this point in the history
  • Loading branch information
junseoparkk committed Oct 2, 2024
1 parent 1017f82 commit a402043
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void inviteUser(LoungeInviteDto request, Long inviterId) {
public void updateInvitedUserStatus(Long userId, Long loungeId) {
User invitedUser = userService.getUserById(userId);
Lounge findLounge = loungeService.getLoungeById(loungeId);
loungeSharerService.updateInvitedUserStatus(invitedUser, findLounge);
loungeSharerService.updateInvitedUserStatus(invitedUser.getId(), findLounge.getId());
}

// 라운지 내 유저 검색
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class LoungeSharerService {
private final LoungeSharerRepository loungeSharerRepository;

public void createAndSaveLoungeSharer(User user, Lounge lounge) {
// 라운지 최대 개수를 초과하는지 검증
if (isOverMaximumCountLounge(user.getId())) {
throw new LoungeException(MAXIMUM_LOUNGE_LIMIT_EXCEEDED_EXCEPTION);
}
Expand All @@ -54,12 +53,18 @@ public void inviteUser(User user, Lounge lounge, Long inviterId) {
}

// FIXME:
public void updateInvitedUserStatus(User invitedUser, Lounge lounge) {
LoungeSharer findSharer = loungeSharerRepository.findByUserIdAndLoungeId(invitedUser.getId(), lounge.getId());
if (!findSharer.isActive()) {
findSharer.updateStatusActive();
loungeSharerRepository.save(findSharer);
public void updateInvitedUserStatus(Long invitedUserId, Long loungeId) {
LoungeSharer loungeSharer = loungeSharerRepository.findByUserIdAndLoungeId(invitedUserId, loungeId)
.orElseThrow(() -> new LoungeException(INVALID_LOUNGE_SHARER_EXCEPTION));
if (loungeSharer.isActive()) {
throw new LoungeException(ALREADY_EXISTS_LOUNGE_USER_EXCEPTION);
}

if (isOverMaximumCountLounge(invitedUserId)) {
throw new LoungeException(MAXIMUM_LOUNGE_LIMIT_EXCEEDED_EXCEPTION);
}
loungeSharer.updateStatusActive();
loungeSharerRepository.save(loungeSharer);
}

public List<LoungeSharerInfoResponseDto> searchLoungeSharer(Long userId, String nickname, Lounge lounge) {
Expand Down

0 comments on commit a402043

Please sign in to comment.