mirror of https://github.com/sualko/cloud_bbb
lint lib
parent
4f49128ca2
commit
80a8e73cd5
|
@ -16,154 +16,154 @@ use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
|
||||||
class JoinController extends PublicShareController
|
class JoinController extends PublicShareController
|
||||||
{
|
{
|
||||||
/** @var RoomService */
|
/** @var RoomService */
|
||||||
private $service;
|
private $service;
|
||||||
|
|
||||||
/** @var IUserSession */
|
/** @var IUserSession */
|
||||||
private $userSession;
|
private $userSession;
|
||||||
|
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
/** @var IURLGenerator */
|
/** @var IURLGenerator */
|
||||||
private $urlGenerator;
|
private $urlGenerator;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $appName,
|
string $appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
ISession $session,
|
ISession $session,
|
||||||
RoomService $service,
|
RoomService $service,
|
||||||
IUserSession $userSession,
|
IUserSession $userSession,
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
IURLGenerator $urlGenerator
|
IURLGenerator $urlGenerator
|
||||||
) {
|
) {
|
||||||
parent::__construct($appName, $request, $session);
|
parent::__construct($appName, $request, $session);
|
||||||
|
|
||||||
$this->service = $service;
|
$this->service = $service;
|
||||||
$this->userSession = $userSession;
|
$this->userSession = $userSession;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getPasswordHash(): string
|
protected function getPasswordHash(): string
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the token of this share. If the token is invalid this controller
|
* Validate the token of this share. If the token is invalid this controller
|
||||||
* will return a 404.
|
* will return a 404.
|
||||||
*/
|
*/
|
||||||
public function isValidToken(): bool
|
public function isValidToken(): bool
|
||||||
{
|
{
|
||||||
$room = $this->service->findByUid($this->getToken());
|
$room = $this->service->findByUid($this->getToken());
|
||||||
|
|
||||||
return $room !== null;
|
return $room !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to specify if this share is password protected
|
* Allows you to specify if this share is password protected
|
||||||
*/
|
*/
|
||||||
protected function isPasswordProtected(): bool
|
protected function isPasswordProtected(): bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @PublicPage
|
* @PublicPage
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*/
|
*/
|
||||||
public function index($displayname, $u, $filename)
|
public function index($displayname, $u, $filename)
|
||||||
{
|
{
|
||||||
$room = $this->service->findByUid($this->getToken());
|
$room = $this->service->findByUid($this->getToken());
|
||||||
|
|
||||||
if ($room === null) {
|
if ($room === null) {
|
||||||
return 'Room not found';
|
return 'Room not found';
|
||||||
}
|
}
|
||||||
|
|
||||||
$uid = null;
|
$uid = null;
|
||||||
$url = null;
|
$url = null;
|
||||||
|
|
||||||
if ($this->userSession->isLoggedIn()) {
|
if ($this->userSession->isLoggedIn()) {
|
||||||
$user = $this->userSession->getUser();
|
$user = $this->userSession->getUser();
|
||||||
$displayname = $user->getDisplayName();
|
$displayname = $user->getDisplayName();
|
||||||
$uid = $user->getUID();
|
$uid = $user->getUID();
|
||||||
$url = $u;
|
$url = $u;
|
||||||
} elseif (empty($displayname) || strlen($displayname) < 3) {
|
} elseif (empty($displayname) || strlen($displayname) < 3) {
|
||||||
$apiUrl = $this->config->getAppValue($this->appName, 'api.url');
|
$apiUrl = $this->config->getAppValue($this->appName, 'api.url');
|
||||||
$response = new TemplateResponse($this->appName, 'publicdisplayname', [
|
$response = new TemplateResponse($this->appName, 'publicdisplayname', [
|
||||||
'wrongdisplayname' => !empty($displayname) && strlen($displayname) < 3
|
'wrongdisplayname' => !empty($displayname) && strlen($displayname) < 3
|
||||||
], 'guest');
|
], 'guest');
|
||||||
|
|
||||||
$parsedApiUrl = parse_url($apiUrl);
|
$parsedApiUrl = parse_url($apiUrl);
|
||||||
|
|
||||||
if ($parsedApiUrl === false) {
|
if ($parsedApiUrl === false) {
|
||||||
throw new \Exception('No valid api url provided');
|
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)
|
private function processPublicJoin($room, $displayname, $uid, $presentation, $filename)
|
||||||
{
|
{
|
||||||
$apiUrl = $this->config->getAppValue($this->appName, 'api.url');
|
$apiUrl = $this->config->getAppValue($this->appName, 'api.url');
|
||||||
$secret = $this->config->getAppValue($this->appName, 'api.secret');
|
$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 = new CreateMeetingParameters($room->uid, $room->name);
|
||||||
$createMeetingParams->setAttendeePassword($room->attendeePassword);
|
$createMeetingParams->setAttendeePassword($room->attendeePassword);
|
||||||
$createMeetingParams->setModeratorPassword($room->moderatorPassword);
|
$createMeetingParams->setModeratorPassword($room->moderatorPassword);
|
||||||
$createMeetingParams->setRecord($room->record);
|
$createMeetingParams->setRecord($room->record);
|
||||||
$createMeetingParams->setLogoutUrl($this->urlGenerator->getBaseUrl());
|
$createMeetingParams->setLogoutUrl($this->urlGenerator->getBaseUrl());
|
||||||
|
|
||||||
$invitationUrl = $this->urlGenerator->getAbsoluteURL($this->request->getPathInfo());
|
$invitationUrl = $this->urlGenerator->getAbsoluteURL($this->request->getPathInfo());
|
||||||
$createMeetingParams->setModeratorOnlyMessage('To invite someone to the meeting, send them this link: ' . $invitationUrl);
|
$createMeetingParams->setModeratorOnlyMessage('To invite someone to the meeting, send them this link: ' . $invitationUrl);
|
||||||
|
|
||||||
if (!empty($room->welcome)) {
|
if (!empty($room->welcome)) {
|
||||||
$createMeetingParams->setWelcomeMessage($room->welcome);
|
$createMeetingParams->setWelcomeMessage($room->welcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($room->maxParticipants > 0) {
|
if ($room->maxParticipants > 0) {
|
||||||
$createMeetingParams->setMaxParticipants($room->maxParticipants);
|
$createMeetingParams->setMaxParticipants($room->maxParticipants);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($presentation) {
|
if ($presentation) {
|
||||||
$createMeetingParams->addPresentation($presentation, null, $filename);
|
$createMeetingParams->addPresentation($presentation, null, $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $bbb->createMeeting($createMeetingParams);
|
$response = $bbb->createMeeting($createMeetingParams);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
throw new \Exception('Can not process create request');
|
throw new \Exception('Can not process create request');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
throw new \Exception('Can not create meeting');
|
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->setCreationTime($response->getCreationTime());
|
||||||
$joinMeetingParams->setJoinViaHtml5(true);
|
$joinMeetingParams->setJoinViaHtml5(true);
|
||||||
|
|
||||||
if ($uid) {
|
if ($uid) {
|
||||||
$joinMeetingParams->setUserId($uid);
|
$joinMeetingParams->setUserId($uid);
|
||||||
// $joinMeetingParams->setAvatarURL();
|
// $joinMeetingParams->setAvatarURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
$joinMeetingParams->setRedirect(true);
|
$joinMeetingParams->setRedirect(true);
|
||||||
$joinUrl = $bbb->getJoinMeetingURL($joinMeetingParams);
|
$joinUrl = $bbb->getJoinMeetingURL($joinMeetingParams);
|
||||||
|
|
||||||
return new RedirectResponse($joinUrl);
|
return new RedirectResponse($joinUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue