service = $service; $this->userSession = $userSession; $this->config = $config; $this->api = $api; } public function setToken(string $token) { $this->token = $token; $this->room = null; } public function isValidToken(): bool { $room = $this->getRoom(); return $room !== null; } /** * @PublicPage * @NoCSRFRequired */ public function index($displayname, $u = '', $filename = '') { $room = $this->getRoom(); if ($room === null) { throw new NotFoundException(); } $userId = null; $presentation = null; if ($this->userSession->isLoggedIn()) { $user = $this->userSession->getUser(); $displayname = $user->getDisplayName(); $userId = $user->getUID(); if ($userId === $room->userId) { $presentation = new Presentation($u, $filename); } } elseif (empty($displayname) || strlen($displayname) < 3) { $response = new TemplateResponse($this->appName, 'publicdisplayname', [ 'room' => $room->name, 'wrongdisplayname' => !empty($displayname) && strlen($displayname) < 3 ], 'guest'); $this->addFormActionDomain($response); return $response; } $creationDate = $this->api->createMeeting($room, $presentation); $joinUrl = $this->api->createJoinUrl($room, $creationDate, $displayname, $userId); return new RedirectResponse($joinUrl); } private function addFormActionDomain($response) { $apiUrl = $this->config->getAppValue($this->appName, 'api.url'); $parsedApiUrl = parse_url($apiUrl); if ($parsedApiUrl === false) { throw new \Exception('No valid api url provided'); } $response->getContentSecurityPolicy()->addAllowedFormActionDomain(($parsedApiUrl['scheme'] ?: 'https') . '://' . $parsedApiUrl['host']); } private function getRoom(): Room { if ($this->room === null) { $this->room = $this->service->findByUid($this->token); } return $this->room; } }