diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AppInfo/Application.php | 4 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 46 | ||||
-rw-r--r-- | lib/Files/TemplateLoader.php | 4 | ||||
-rw-r--r-- | lib/Manager.php | 3 | ||||
-rw-r--r-- | lib/Maps/MapsPluginLoader.php | 21 | ||||
-rw-r--r-- | lib/Service/BreakoutRoomService.php | 3 | ||||
-rw-r--r-- | lib/Service/RecordingService.php | 2 | ||||
-rw-r--r-- | lib/Service/RoomService.php | 2 |
8 files changed, 54 insertions, 31 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index cf9803e6f..b54946725 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -198,7 +198,7 @@ class Application extends App implements IBootstrap { /** @var IProviderManager $resourceManager */ $resourceManager = $server->get(IProviderManager::class); $resourceManager->registerResourceProvider(ConversationProvider::class); - $server->getEventDispatcher()->addListener(LoadAdditionalScriptsEvent::class, function () { + $server->getEventDispatcher()->addListener(LoadAdditionalScriptsEvent::class, static function () { Util::addScript(self::APP_ID, 'talk-collections'); }); } @@ -212,7 +212,7 @@ class Application extends App implements IBootstrap { } protected function registerNavigationLink(IServerContainer $server): void { - $server->getNavigationManager()->add(function () use ($server) { + $server->getNavigationManager()->add(static function () use ($server) { /** @var Config $config */ $config = $server->get(Config::class); $user = $server->getUserSession()->getUser(); diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 4272cde23..b4415d0a1 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -1436,7 +1436,8 @@ class RoomController extends AEnvironmentAwareController { public function joinRoom(string $token, string $password = '', bool $force = true): DataResponse { $sessionId = $this->session->getSessionForRoom($token); try { - $room = $this->manager->getRoomForUserByToken($token, $this->userId, $sessionId); + // The participant is just joining, so enforce to not load any session + $room = $this->manager->getRoomForUserByToken($token, $this->userId, null); } catch (RoomNotFoundException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } @@ -1445,35 +1446,34 @@ class RoomController extends AEnvironmentAwareController { $previousParticipant = null; /** @var Session|null $previousSession */ $previousSession = null; - if ($this->userId !== null) { - try { - $previousParticipant = $this->participantService->getParticipant($room, $this->userId, $sessionId); - $previousSession = $previousParticipant->getSession(); - } catch (ParticipantNotFoundException $e) { - } - } else { + + if ($sessionId !== null) { try { - $previousParticipant = $this->participantService->getParticipantBySession($room, $sessionId); + if ($this->userId !== null) { + $previousParticipant = $this->participantService->getParticipant($room, $this->userId, $sessionId); + } else { + $previousParticipant = $this->participantService->getParticipantBySession($room, $sessionId); + } $previousSession = $previousParticipant->getSession(); } catch (ParticipantNotFoundException $e) { } - } - if ($previousSession instanceof Session && $previousSession->getSessionId() !== '0') { - if ($force === false && $previousSession->getInCall() !== Participant::FLAG_DISCONNECTED) { - // Previous session is/was active in the call, show a warning - return new DataResponse([ - 'sessionId' => $previousSession->getSessionId(), - 'inCall' => $previousSession->getInCall(), - 'lastPing' => $previousSession->getLastPing(), - ], Http::STATUS_CONFLICT); - } + if ($previousSession instanceof Session && $previousSession->getSessionId() === $sessionId) { + if ($force === false && $previousSession->getInCall() !== Participant::FLAG_DISCONNECTED) { + // Previous session is/was active in the call, show a warning + return new DataResponse([ + 'sessionId' => $previousSession->getSessionId(), + 'inCall' => $previousSession->getInCall(), + 'lastPing' => $previousSession->getLastPing(), + ], Http::STATUS_CONFLICT); + } - if ($previousSession->getInCall() !== Participant::FLAG_DISCONNECTED) { - $this->participantService->changeInCall($room, $previousParticipant, Participant::FLAG_DISCONNECTED); - } + if ($previousSession->getInCall() !== Participant::FLAG_DISCONNECTED) { + $this->participantService->changeInCall($room, $previousParticipant, Participant::FLAG_DISCONNECTED); + } - $this->participantService->leaveRoomAsSession($room, $previousParticipant, true); + $this->participantService->leaveRoomAsSession($room, $previousParticipant, true); + } } $user = $this->userManager->get($this->userId); diff --git a/lib/Files/TemplateLoader.php b/lib/Files/TemplateLoader.php index efaf5384f..5bb20f75b 100644 --- a/lib/Files/TemplateLoader.php +++ b/lib/Files/TemplateLoader.php @@ -97,7 +97,9 @@ class TemplateLoader implements IEventListener { Util::addStyle(Application::APP_ID, 'At'); Util::addStyle(Application::APP_ID, 'icons'); - Util::addScript(Application::APP_ID, 'talk-files-sidebar'); + if (strpos(\OC::$server->getRequest()->getPathInfo(), '/apps/maps') !== 0) { + Util::addScript(Application::APP_ID, 'talk-files-sidebar'); + } if ($user instanceof IUser) { $this->publishInitialStateForUser($user, $this->rootFolder, $this->appManager); diff --git a/lib/Manager.php b/lib/Manager.php index 6f68ab02d..4beb0b47c 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -788,7 +788,8 @@ class Manager { $helper->selectRoomsTable($query); $query->from('talk_rooms', 'r') ->where($query->expr()->eq('r.object_type', $query->createNamedParameter($objectType))) - ->andWhere($query->expr()->eq('r.object_id', $query->createNamedParameter($objectId))); + ->andWhere($query->expr()->eq('r.object_id', $query->createNamedParameter($objectId))) + ->orderBy('r.id'); $result = $query->executeQuery(); $row = $result->fetch(); diff --git a/lib/Maps/MapsPluginLoader.php b/lib/Maps/MapsPluginLoader.php index 6d133283b..a365b12d7 100644 --- a/lib/Maps/MapsPluginLoader.php +++ b/lib/Maps/MapsPluginLoader.php @@ -23,21 +23,31 @@ declare(strict_types=1); namespace OCA\Talk\Maps; +use OCA\Talk\Config; use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\IRequest; +use OCP\IUser; +use OCP\IUserSession; use OCP\Util; /** * @template-implements IEventListener<Event> */ class MapsPluginLoader implements IEventListener { - /** @var IRequest */ - private $request; + protected IRequest $request; + protected Config $talkConfig; + protected IUserSession $userSession; - public function __construct(IRequest $request) { + public function __construct( + IRequest $request, + Config $talkConfig, + IUserSession $userSession + ) { $this->request = $request; + $this->talkConfig = $talkConfig; + $this->userSession = $userSession; } public function handle(Event $event): void { @@ -49,6 +59,11 @@ class MapsPluginLoader implements IEventListener { return; } + $user = $this->userSession->getUser(); + if ($user instanceof IUser && $this->talkConfig->isDisabledForUser($user)) { + return; + } + if (strpos($this->request->getPathInfo(), '/apps/maps') === 0) { Util::addScript('spreed', 'talk-collections'); Util::addScript('spreed', 'talk-maps'); diff --git a/lib/Service/BreakoutRoomService.php b/lib/Service/BreakoutRoomService.php index e3400f74d..caf3c8bcd 100644 --- a/lib/Service/BreakoutRoomService.php +++ b/lib/Service/BreakoutRoomService.php @@ -202,6 +202,9 @@ class BreakoutRoomService { $breakoutRooms = $this->manager->getMultipleRoomsByObject(BreakoutRoom::PARENT_OBJECT_TYPE, $parent->getToken()); $amount = count($breakoutRooms); + usort($breakoutRooms, static function (Room $roomA, Room $roomB) { + return $roomA->getId() - $roomB->getId(); + }); $cleanedMap = $this->parseAttendeeMap($attendeeMap, $amount); $attendeeIds = array_keys($cleanedMap); diff --git a/lib/Service/RecordingService.php b/lib/Service/RecordingService.php index 7a26c4ebb..2eaafb999 100644 --- a/lib/Service/RecordingService.php +++ b/lib/Service/RecordingService.php @@ -83,7 +83,7 @@ class RecordingService { public function stop(Room $room): void { if ($room->getCallRecording() === Room::RECORDING_NONE) { - throw new InvalidArgumentException('recording'); + return; } $this->roomService->setCallRecording($room); } diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index bcb36312e..572a12951 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -369,6 +369,8 @@ class RoomService { /** * @param Room $room * @param integer $status 0 none|1 video|2 audio + * @throws \InvalidArgumentException When the status is invalid, not Room::RECORDING_* + * @throws \InvalidArgumentException When trying to start */ public function setCallRecording(Room $room, int $status = Room::RECORDING_NONE): void { if (!$this->config->isRecordingEnabled() && $status !== Room::RECORDING_NONE) { |