Skip to content

Commit 68ccea1

Browse files
committed
[FEAT] 방 삭제 로직 변경
1 parent 2973b2d commit 68ccea1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/com/example/be/web/controller/OpenviduController.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ public ResponseEntity<String> receiveWebhook(@RequestHeader("Authorization") Str
7474
System.out.println("Room created: " + roomName);
7575
}
7676
}
77-
case "room_finished" -> {
78-
Room room = roomRepository.findByTitle(roomName);
79-
if (room != null) {
80-
roomRepository.delete(room);
81-
System.out.println("Room deleted: " + roomName);
82-
}
83-
}
8477
case "participant_joined" -> {
8578
Room room = roomRepository.findByTitle(roomName);
8679
if (room != null) {
@@ -91,10 +84,17 @@ public ResponseEntity<String> receiveWebhook(@RequestHeader("Authorization") Str
9184
}
9285
case "participant_left" -> {
9386
Room room = roomRepository.findByTitle(roomName);
94-
if (room != null && room.getParticipantCount() > 0) {
87+
if (room != null) {
9588
room.setParticipantCount(room.getParticipantCount() - 1);
9689
roomRepository.save(room);
90+
}
91+
if (room != null && room.getParticipantCount() > 0) {
92+
roomRepository.save(room);
9793
System.out.println("Participant left. Current count: " + room.getParticipantCount());
94+
}
95+
else if (room != null && room.getParticipantCount() == 0) {
96+
roomRepository.delete(room);
97+
System.out.println("Room deleted: " + roomName);
9898
}
9999
}
100100
}

0 commit comments

Comments
 (0)