From 80a8e73cd5f48611aac5f2089a4109a3e9d412a1 Mon Sep 17 00:00:00 2001 From: sualko Date: Sun, 26 Apr 2020 12:14:06 +0200 Subject: [PATCH] lint lib --- lib/Controller/JoinController.php | 232 +++++++++++++++--------------- 1 file changed, 116 insertions(+), 116 deletions(-) diff --git a/lib/Controller/JoinController.php b/lib/Controller/JoinController.php index cee5d9b..afbc851 100644 --- a/lib/Controller/JoinController.php +++ b/lib/Controller/JoinController.php @@ -16,154 +16,154 @@ use OCP\AppFramework\Http\TemplateResponse; class JoinController extends PublicShareController { - /** @var RoomService */ - private $service; + /** @var RoomService */ + private $service; - /** @var IUserSession */ - private $userSession; + /** @var IUserSession */ + private $userSession; - /** @var IConfig */ - private $config; + /** @var IConfig */ + private $config; - /** @var IURLGenerator */ - private $urlGenerator; + /** @var IURLGenerator */ + private $urlGenerator; - public function __construct( - string $appName, - IRequest $request, - ISession $session, - RoomService $service, - IUserSession $userSession, - IConfig $config, - IURLGenerator $urlGenerator - ) { - parent::__construct($appName, $request, $session); + public function __construct( + string $appName, + IRequest $request, + ISession $session, + RoomService $service, + IUserSession $userSession, + IConfig $config, + IURLGenerator $urlGenerator + ) { + parent::__construct($appName, $request, $session); - $this->service = $service; - $this->userSession = $userSession; - $this->config = $config; - $this->urlGenerator = $urlGenerator; - } + $this->service = $service; + $this->userSession = $userSession; + $this->config = $config; + $this->urlGenerator = $urlGenerator; + } - protected function getPasswordHash(): string - { - return ''; - } + protected function getPasswordHash(): string + { + return ''; + } - /** - * Validate the token of this share. If the token is invalid this controller - * will return a 404. - */ - public function isValidToken(): bool - { - $room = $this->service->findByUid($this->getToken()); + /** + * Validate the token of this share. If the token is invalid this controller + * will return a 404. + */ + public function isValidToken(): bool + { + $room = $this->service->findByUid($this->getToken()); - return $room !== null; - } + return $room !== null; + } - /** - * Allows you to specify if this share is password protected - */ - protected function isPasswordProtected(): bool - { - return false; - } + /** + * Allows you to specify if this share is password protected + */ + protected function isPasswordProtected(): bool + { + return false; + } - /** - * @PublicPage - * @NoCSRFRequired - */ - public function index($displayname, $u, $filename) - { - $room = $this->service->findByUid($this->getToken()); + /** + * @PublicPage + * @NoCSRFRequired + */ + public function index($displayname, $u, $filename) + { + $room = $this->service->findByUid($this->getToken()); - if ($room === null) { - return 'Room not found'; - } + if ($room === null) { + return 'Room not found'; + } - $uid = null; - $url = null; + $uid = null; + $url = null; - if ($this->userSession->isLoggedIn()) { - $user = $this->userSession->getUser(); - $displayname = $user->getDisplayName(); - $uid = $user->getUID(); - $url = $u; - } elseif (empty($displayname) || strlen($displayname) < 3) { - $apiUrl = $this->config->getAppValue($this->appName, 'api.url'); - $response = new TemplateResponse($this->appName, 'publicdisplayname', [ - 'wrongdisplayname' => !empty($displayname) && strlen($displayname) < 3 - ], 'guest'); + if ($this->userSession->isLoggedIn()) { + $user = $this->userSession->getUser(); + $displayname = $user->getDisplayName(); + $uid = $user->getUID(); + $url = $u; + } elseif (empty($displayname) || strlen($displayname) < 3) { + $apiUrl = $this->config->getAppValue($this->appName, 'api.url'); + $response = new TemplateResponse($this->appName, 'publicdisplayname', [ + 'wrongdisplayname' => !empty($displayname) && strlen($displayname) < 3 + ], 'guest'); - $parsedApiUrl = parse_url($apiUrl); + $parsedApiUrl = parse_url($apiUrl); - if ($parsedApiUrl === false) { - throw new \Exception('No valid api url provided'); - } + if ($parsedApiUrl === false) { + throw new \Exception('No valid api url provided'); + } - $response->getContentSecurityPolicy()->addAllowedFormActionDomain(($parsedApiUrl['scheme'] ?: 'https') . '://' . $parsedApiUrl['host']); + $response->getContentSecurityPolicy()->addAllowedFormActionDomain(($parsedApiUrl['scheme'] ?: 'https') . '://' . $parsedApiUrl['host']); - return $response; - } + return $response; + } - return $this->processPublicJoin($room, $displayname, $uid, $url, $filename); - } + return $this->processPublicJoin($room, $displayname, $uid, $url, $filename); + } - private function processPublicJoin($room, $displayname, $uid, $presentation, $filename) - { - $apiUrl = $this->config->getAppValue($this->appName, 'api.url'); - $secret = $this->config->getAppValue($this->appName, 'api.secret'); + private function processPublicJoin($room, $displayname, $uid, $presentation, $filename) + { + $apiUrl = $this->config->getAppValue($this->appName, 'api.url'); + $secret = $this->config->getAppValue($this->appName, 'api.secret'); - $bbb = new BigBlueButton($apiUrl, $secret); + $bbb = new BigBlueButton($apiUrl, $secret); - $createMeetingParams = new CreateMeetingParameters($room->uid, $room->name); - $createMeetingParams->setAttendeePassword($room->attendeePassword); - $createMeetingParams->setModeratorPassword($room->moderatorPassword); - $createMeetingParams->setRecord($room->record); - $createMeetingParams->setLogoutUrl($this->urlGenerator->getBaseUrl()); + $createMeetingParams = new CreateMeetingParameters($room->uid, $room->name); + $createMeetingParams->setAttendeePassword($room->attendeePassword); + $createMeetingParams->setModeratorPassword($room->moderatorPassword); + $createMeetingParams->setRecord($room->record); + $createMeetingParams->setLogoutUrl($this->urlGenerator->getBaseUrl()); - $invitationUrl = $this->urlGenerator->getAbsoluteURL($this->request->getPathInfo()); - $createMeetingParams->setModeratorOnlyMessage('To invite someone to the meeting, send them this link: ' . $invitationUrl); + $invitationUrl = $this->urlGenerator->getAbsoluteURL($this->request->getPathInfo()); + $createMeetingParams->setModeratorOnlyMessage('To invite someone to the meeting, send them this link: ' . $invitationUrl); - if (!empty($room->welcome)) { - $createMeetingParams->setWelcomeMessage($room->welcome); - } + if (!empty($room->welcome)) { + $createMeetingParams->setWelcomeMessage($room->welcome); + } - if ($room->maxParticipants > 0) { - $createMeetingParams->setMaxParticipants($room->maxParticipants); - } + if ($room->maxParticipants > 0) { + $createMeetingParams->setMaxParticipants($room->maxParticipants); + } - if ($presentation) { - $createMeetingParams->addPresentation($presentation, null, $filename); - } + if ($presentation) { + $createMeetingParams->addPresentation($presentation, null, $filename); + } - try { - $response = $bbb->createMeeting($createMeetingParams); - } catch (\Exception $e) { - throw $e; - throw new \Exception('Can not process create request'); - } + try { + $response = $bbb->createMeeting($createMeetingParams); + } catch (\Exception $e) { + throw $e; + throw new \Exception('Can not process create request'); + } - if ($response->failed()) { - throw new \Exception('Can not create meeting'); - } + if ($response->failed()) { + throw new \Exception('Can not create meeting'); + } - $password = $uid === $room->userId ? $room->moderatorPassword : $room->attendeePassword; + $password = $uid === $room->userId ? $room->moderatorPassword : $room->attendeePassword; - $joinMeetingParams = new JoinMeetingParameters($room->uid, $displayname, $password); + $joinMeetingParams = new JoinMeetingParameters($room->uid, $displayname, $password); - $joinMeetingParams->setCreationTime($response->getCreationTime()); - $joinMeetingParams->setJoinViaHtml5(true); + $joinMeetingParams->setCreationTime($response->getCreationTime()); + $joinMeetingParams->setJoinViaHtml5(true); - if ($uid) { - $joinMeetingParams->setUserId($uid); - // $joinMeetingParams->setAvatarURL(); - } + if ($uid) { + $joinMeetingParams->setUserId($uid); + // $joinMeetingParams->setAvatarURL(); + } - $joinMeetingParams->setRedirect(true); - $joinUrl = $bbb->getJoinMeetingURL($joinMeetingParams); + $joinMeetingParams->setRedirect(true); + $joinUrl = $bbb->getJoinMeetingURL($joinMeetingParams); - return new RedirectResponse($joinUrl); - } + return new RedirectResponse($joinUrl); + } }