Skip to content

Commit

Permalink
[fix] host일 때 방에 참가하는 로직 건너 뛰도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hysong4u committed Feb 21, 2024
1 parent bdd4e14 commit c87b4ca
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,20 @@ public RoomInviteResponseDto getRoomInviteInfo(String invitationCode) {
public JoinRoomResponseDto findAndJoinRoom(Long memberId, String invitationCode) {
Member member = findMemberByIdOrThrow(memberId);
Room room = findByInvitationOrThrow(invitationCode);
joinRoom(member, room);
if (!isOwner(memberId, room.getId())) {
joinRoom(member, room);
}
return JoinRoomResponseDto.of(room.getId());
}

public Boolean isOwner(Long memberId, Long roomId) {
Optional<Member> member = memberRepository.findById(memberId);
Optional<Room> room = roomRepository.findById(roomId);
Boolean isOwner = member.get().getId().equals(room.get().getHost().getId());
return isOwner;
}


@Transactional(readOnly = true)
public RoomMainResponseDto getRoomMainInfo(Long memberId, Long roomId) {
Member member = findMemberByIdOrThrow(memberId);
Expand Down

0 comments on commit c87b4ca

Please sign in to comment.