diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2019-08-28 16:12:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-28 16:12:44 +0300 |
commit | 6f1e4bef324eea902da334fcb470bb6e48bcf5cb (patch) | |
tree | 31fcb368f40bb740db49eb309c64f2e08b916532 /lib/Controller | |
parent | b2e30c47080b596d874d22162a4e49f8fc7f94ed (diff) | |
parent | 22be1a93103bc8ef7ddfd65ada12653ba757614f (diff) |
Merge pull request #1926 from nextcloud/feature/382/lobby
⏳ Lobby
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/CallController.php | 3 | ||||
-rw-r--r-- | lib/Controller/ChatController.php | 3 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 26 | ||||
-rw-r--r-- | lib/Controller/SignalingController.php | 2 | ||||
-rw-r--r-- | lib/Controller/WebinaryController.php | 69 |
5 files changed, 96 insertions, 7 deletions
diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php index 73e9b4418..1c4ee3e13 100644 --- a/lib/Controller/CallController.php +++ b/lib/Controller/CallController.php @@ -48,6 +48,7 @@ class CallController extends AEnvironmentAwareController { * @PublicPage * @RequireParticipant * @RequireReadWriteConversation + * @RequireModeratorOrNoLobby * * @return DataResponse */ @@ -75,6 +76,7 @@ class CallController extends AEnvironmentAwareController { * @PublicPage * @RequireParticipant * @RequireReadWriteConversation + * @RequireModeratorOrNoLobby * * @param int|null $flags * @return DataResponse @@ -100,6 +102,7 @@ class CallController extends AEnvironmentAwareController { /** * @PublicPage * @RequireParticipant + * @RequireModeratorOrNoLobby * * @return DataResponse */ diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index cf8ebeca4..4a38d0277 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -112,6 +112,7 @@ class ChatController extends AEnvironmentAwareController { * @PublicPage * @RequireParticipant * @RequireReadWriteConversation + * @RequireModeratorOrNoLobby * * Sends a new chat message to the given room. * @@ -193,6 +194,7 @@ class ChatController extends AEnvironmentAwareController { /** * @PublicPage * @RequireParticipant + * @RequireModeratorOrNoLobby * * Receives chat messages from the given room. * @@ -369,6 +371,7 @@ class ChatController extends AEnvironmentAwareController { * @PublicPage * @RequireParticipant * @RequireReadWriteConversation + * @RequireModeratorOrNoLobby * * @param string $search * @param int $limit diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index bef74ff46..45f85b50f 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -37,6 +37,7 @@ use OCA\Spreed\Manager; use OCA\Spreed\Participant; use OCA\Spreed\Room; use OCA\Spreed\TalkSession; +use OCA\Spreed\Webinary; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Utility\ITimeFactory; @@ -201,6 +202,13 @@ class RoomController extends AEnvironmentAwareController { $lastActivity = 0; } + $lobbyTimer = $room->getLobbyTimer(); + if ($lobbyTimer instanceof \DateTimeInterface) { + $lobbyTimer = $lobbyTimer->getTimestamp(); + } else { + $lobbyTimer = 0; + } + $roomData = array_merge($roomData, [ 'name' => $room->getName(), 'displayName' => $room->getDisplayName($currentParticipant->getUser()), @@ -216,6 +224,10 @@ class RoomController extends AEnvironmentAwareController { 'lastActivity' => $lastActivity, 'isFavorite' => $currentParticipant->isFavorite(), 'notificationLevel' => $currentParticipant->getNotificationLevel(), + 'lobbyState' => $room->getLobbyState(), + 'lobbyTimer' => $lobbyTimer, + 'lastPing' => $currentParticipant->getLastPing(), + 'sessionId' => $currentParticipant->getSessionId(), ]); if ($roomData['notificationLevel'] === Participant::NOTIFY_DEFAULT) { @@ -226,6 +238,12 @@ class RoomController extends AEnvironmentAwareController { } } + if ($room->getLobbyState() === Webinary::LOBBY_NON_MODERATORS && + !$currentParticipant->hasModeratorPermissions()) { + // No participants and chat messages for users in the lobby. + return $roomData; + } + $currentUser = $this->userManager->get($currentParticipant->getUser()); if ($currentUser instanceof IUser) { $lastReadMessage = $currentParticipant->getLastReadMessage(); @@ -295,8 +313,6 @@ class RoomController extends AEnvironmentAwareController { } $roomData = array_merge($roomData, [ - 'lastPing' => $currentParticipant->getLastPing(), - 'sessionId' => $currentParticipant->getSessionId(), 'participants' => $participantList, 'numGuests' => $numActiveGuests, 'lastMessage' => $lastMessage, @@ -569,6 +585,7 @@ class RoomController extends AEnvironmentAwareController { /** * @PublicPage * @RequireParticipant + * @RequireModeratorOrNoLobby * * @return DataResponse */ @@ -894,10 +911,9 @@ class RoomController extends AEnvironmentAwareController { $this->session->removePasswordForRoom($token); $this->session->setSessionForRoom($token, $newSessionId); $room->ping($this->userId, $newSessionId, $this->timeFactory->getTime()); + $currentParticipant = $room->getParticipantBySession($newSessionId); - return new DataResponse([ - 'sessionId' => $newSessionId, - ]); + return new DataResponse($this->formatRoom($room, $currentParticipant)); } /** diff --git a/lib/Controller/SignalingController.php b/lib/Controller/SignalingController.php index 8a1541589..60b3f4437 100644 --- a/lib/Controller/SignalingController.php +++ b/lib/Controller/SignalingController.php @@ -417,8 +417,6 @@ class SignalingController extends OCSController { } if ($action === 'join') { - // Rooms get sorted by last ping time for users, so make sure to - // update when a user joins a room. $room->ping($userId, $sessionId, $this->timeFactory->getTime()); } else if ($action === 'leave') { if (!empty($userId)) { diff --git a/lib/Controller/WebinaryController.php b/lib/Controller/WebinaryController.php new file mode 100644 index 000000000..176e30529 --- /dev/null +++ b/lib/Controller/WebinaryController.php @@ -0,0 +1,69 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> + * + * @author Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Spreed\Controller; + +use OCP\AppFramework\Http; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Utility\ITimeFactory; +use OCP\IRequest; + +class WebinaryController extends AEnvironmentAwareController { + + /** @var ITimeFactory */ + protected $timeFactory; + + public function __construct(string $appName, + IRequest $request, + ITimeFactory $timeFactory) { + parent::__construct($appName, $request); + $this->timeFactory = $timeFactory; + } + + /** + * @NoAdminRequired + * @RequireModeratorParticipant + * + * @param int $state + * @param int|null $timer + * @return DataResponse + */ + public function setLobby(int $state, ?int $timer = null): DataResponse { + $timerDateTime = null; + if ($timer !== null && $timer > 0) { + try { + $timerDateTime = $this->timeFactory->getDateTime('@' . $timer); + $timerDateTime->setTimezone(new \DateTimeZone('UTC')); + } catch (\Exception $e) { + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + } + + if (!$this->room->setLobby($state, $timerDateTime)) { + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + + return new DataResponse(); + } +} |