diff options
author | Joas Schilling <coding@schilljs.com> | 2023-01-02 15:55:14 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-01-04 17:35:22 +0100 |
commit | ffd0f2525eca3f5fc0c7a9efaed3a5cad20d73b5 (patch) | |
tree | b0e81ed7f582f5a23d5de2411fc51ef25cfd3346 /lib/Controller/RoomController.php | |
parent | b45bb9b263950fd5b9575d4a3aee0bc105bfb2ca (diff) |
Add user to parent room when added to a breakout room
Also makes that a "move" function, so the user is removed from their previous breakout room
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller/RoomController.php')
-rw-r--r-- | lib/Controller/RoomController.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 5b4e71e89..9128b5035 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -1120,6 +1120,11 @@ class RoomController extends AEnvironmentAwareController { return new DataResponse([], Http::STATUS_BAD_REQUEST); } + if ($source !== 'users' && $this->room->getObjectType() === BreakoutRoom::PARENT_OBJECT_TYPE) { + // Can only add users to breakout rooms + return new DataResponse(['error' => 'source'], Http::STATUS_BAD_REQUEST); + } + $participants = $this->participantService->getParticipantsForRoom($this->room); $participantsByUserId = []; $remoteParticipantsByFederatedId = []; @@ -1223,6 +1228,28 @@ class RoomController extends AEnvironmentAwareController { $addedBy = $this->userManager->get($this->userId); + if ($source === 'users' && $this->room->getObjectType() === BreakoutRoom::PARENT_OBJECT_TYPE) { + $parentRoom = $this->manager->getRoomByToken($this->room->getObjectId()); + + // Also add to parent room in case the user is missing + try { + $this->participantService->getParticipantByActor( + $parentRoom, + Attendee::ACTOR_USERS, + $newParticipant + ); + } catch (ParticipantNotFoundException $e) { + $this->participantService->addUsers($parentRoom, $participantsToAdd, $addedBy); + } + + // Remove from previous breakout room in case the user is moved + try { + $this->breakoutRoomService->removeAttendeeFromBreakoutRoom($parentRoom, Attendee::ACTOR_USERS, $newParticipant); + } catch (\InvalidArgumentException $e) { + return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST); + } + } + // add the remaining users in batch $this->participantService->addUsers($this->room, $participantsToAdd, $addedBy); |