From 5d63a47b7d2416ece39fc702b101538860a94b3b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 3 Jan 2023 11:07:55 +0100 Subject: [PATCH] Remove attendees from breakout rooms as well Signed-off-by: Joas Schilling --- lib/Service/BreakoutRoomService.php | 5 ++- lib/Service/ParticipantService.php | 22 +++++++++++ .../conversation/breakout-rooms.feature | 37 +++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/lib/Service/BreakoutRoomService.php b/lib/Service/BreakoutRoomService.php index f1b27c0efb..ac225017e7 100644 --- a/lib/Service/BreakoutRoomService.php +++ b/lib/Service/BreakoutRoomService.php @@ -543,10 +543,11 @@ class BreakoutRoomService { * @param Room $parent * @param string $actorType * @param string $actorId + * @param bool $throwOnModerator * @return void * @throws InvalidArgumentException When being used for a moderator */ - public function removeAttendeeFromBreakoutRoom(Room $parent, string $actorType, string $actorId): void { + public function removeAttendeeFromBreakoutRoom(Room $parent, string $actorType, string $actorId, bool $throwOnModerator = true): void { $breakoutRooms = $this->manager->getMultipleRoomsByObject(BreakoutRoom::PARENT_OBJECT_TYPE, $parent->getToken()); foreach ($breakoutRooms as $breakoutRoom) { @@ -557,7 +558,7 @@ class BreakoutRoomService { $actorId ); - if ($participant->hasModeratorPermissions()) { + if ($throwOnModerator && $participant->hasModeratorPermissions()) { throw new \InvalidArgumentException('moderator'); } diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index d48e448cf0..b3f1b2695d 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -787,6 +787,17 @@ class ParticipantService { $sessions = $this->sessionService->getAllSessionsForAttendee($participant->getAttendee()); + if ($room->getBreakoutRoomMode() !== BreakoutRoom::MODE_NOT_CONFIGURED) { + /** @var BreakoutRoomService $breakoutRoomService */ + $breakoutRoomService = Server::get(BreakoutRoomService::class); + $breakoutRoomService->removeAttendeeFromBreakoutRoom( + $room, + $participant->getAttendee()->getActorType(), + $participant->getAttendee()->getActorId(), + false + ); + } + if ($isUser) { $user = $this->userManager->get($participant->getAttendee()->getActorId()); $event = new RemoveUserEvent($room, $participant, $user, $reason, $sessions); @@ -920,6 +931,17 @@ class ParticipantService { $attendee = $participant->getAttendee(); $sessions = $this->sessionService->getAllSessionsForAttendee($attendee); + if ($room->getBreakoutRoomMode() !== BreakoutRoom::MODE_NOT_CONFIGURED) { + /** @var BreakoutRoomService $breakoutRoomService */ + $breakoutRoomService = Server::get(BreakoutRoomService::class); + $breakoutRoomService->removeAttendeeFromBreakoutRoom( + $room, + $attendee->getActorType(), + $attendee->getActorId(), + false + ); + } + $event = new RemoveUserEvent($room, $participant, $user, $reason, $sessions); $this->dispatcher->dispatch(Room::EVENT_BEFORE_USER_REMOVE, $event); diff --git a/tests/integration/features/conversation/breakout-rooms.feature b/tests/integration/features/conversation/breakout-rooms.feature index 4fe05a9e1c..95ffdde7f7 100644 --- a/tests/integration/features/conversation/breakout-rooms.feature +++ b/tests/integration/features/conversation/breakout-rooms.feature @@ -681,6 +681,43 @@ Feature: conversation/breakout-rooms | 2 | class room | 0 | 1 | 0 | | 2 | Room 2 | 1 | 0 | 0 | + Scenario: Removing a user from the parent also removes them from the breakout room + Given user "participant1" creates room "class room" (v4) + | roomType | 2 | + | roomName | class room | + When user "participant1" adds user "participant2" to room "class room" with 200 (v4) + When user "participant1" adds user "participant3" to room "class room" with 200 (v4) + When user "participant1" adds user "participant4" to room "class room" with 200 (v4) + Then user "participant1" sees the following attendees in room "class room" with 200 (v4) + | actorType | actorId | participantType | + | users | participant1 | 1 | + | users | participant2 | 3 | + | users | participant3 | 3 | + | users | participant4 | 3 | + And user "participant1" promotes "participant2" in room "class room" with 200 (v4) + When user "participant1" creates 2 manual breakout rooms for "class room" with 200 (v1) + | users::participant3 | 0 | + | users::participant4 | 1 | + And user "participant2" is participant of the following rooms (v4) + | type | name | lobbyState | breakoutRoomMode | breakoutRoomStatus | + | 2 | class room | 0 | 2 | 0 | + | 2 | Room 1 | 1 | 0 | 0 | + | 2 | Room 2 | 1 | 0 | 0 | + And user "participant3" is participant of the following rooms (v4) + | type | name | lobbyState | breakoutRoomMode | breakoutRoomStatus | + | 2 | class room | 0 | 2 | 0 | + | 2 | Room 1 | 1 | 0 | 0 | + And user "participant4" is participant of the following rooms (v4) + | type | name | lobbyState | breakoutRoomMode | breakoutRoomStatus | + | 2 | class room | 0 | 2 | 0 | + | 2 | Room 2 | 1 | 0 | 0 | + When user "participant1" removes user "participant2" from room "class room" with 200 (v4) + And user "participant1" removes user "participant3" from room "class room" with 200 (v4) + And user "participant4" removes themselves from room "class room" with 200 (v4) + Then user "participant2" is participant of the following rooms (v4) + And user "participant3" is participant of the following rooms (v4) + And user "participant4" is participant of the following rooms (v4) + Scenario: Only users with normal level can be moved between breakout rooms Given user "participant1" creates room "class room" (v4) | roomType | 2 |