mirror of https://github.com/sualko/cloud_bbb
feat: Default Presentation
generate direct in the DB instead of using getDirectDownload()pull/207/head
parent
9f0f591d7a
commit
7f2372d207
|
@ -2,34 +2,71 @@
|
||||||
|
|
||||||
namespace OCA\BigBlueButton\BigBlueButton;
|
namespace OCA\BigBlueButton\BigBlueButton;
|
||||||
|
|
||||||
|
use OCA\DAV\Db\Direct;
|
||||||
|
use OCA\DAV\Db\DirectMapper;
|
||||||
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
|
use OCP\Files\Folder;
|
||||||
use OCP\Files\Storage\IStorage;
|
use OCP\Files\Storage\IStorage;
|
||||||
|
use OCP\IURLGenerator;
|
||||||
|
use OCP\Security\ISecureRandom;
|
||||||
|
|
||||||
class Presentation
|
class Presentation
|
||||||
{
|
{
|
||||||
private $url;
|
private $url;
|
||||||
|
private $userId;
|
||||||
|
|
||||||
/** @var File*/
|
/** @var File*/
|
||||||
private $file;
|
private $file;
|
||||||
|
|
||||||
/** @var IRootFolder */
|
/** @var Folder */
|
||||||
private $userFolder;
|
private $userFolder;
|
||||||
|
|
||||||
/** @var IStorage */
|
/** @var DirectMapper */
|
||||||
private $storage;
|
private $mapper;
|
||||||
|
|
||||||
public function __construct(string $path, string $userID, IRootFolder $iRootFolder)
|
/** @var ISecureRandom */
|
||||||
{
|
private $random;
|
||||||
$userFolder = $iRootFolder->getUserFolder($userID);
|
|
||||||
$this->file = $userFolder->get($path);
|
/** @var ITimeFactory */
|
||||||
$this->storage = $this->file->getStorage();
|
private $timeFactory;
|
||||||
|
|
||||||
|
/** @var IURLGenerator */
|
||||||
|
private $urlGenerator;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
string $path,
|
||||||
|
string $userId,
|
||||||
|
IRootFolder $iRootFolder,
|
||||||
|
DirectMapper $mapper,
|
||||||
|
ISecureRandom $random,
|
||||||
|
ITimeFactory $timeFactory,
|
||||||
|
IURLGenerator $urlGenerator
|
||||||
|
) {
|
||||||
|
$this->userFolder = $iRootFolder->getUserFolder($userId);
|
||||||
|
$this->file = $this->userFolder->get($path);
|
||||||
|
$this->mapper = $mapper;
|
||||||
|
$this->random = $random;
|
||||||
|
$this->timeFactory = $timeFactory;
|
||||||
|
$this->userId = $userId;
|
||||||
|
$this->urlGenerator = $urlGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateUrl(): string
|
public function generateUrl()
|
||||||
{
|
{
|
||||||
$filePath = $this->file->getInternalPath();
|
$direct = new Direct();
|
||||||
[$url] = $this->storage->getDirectDownload($filePath);
|
$direct->setUserId($this->userId);
|
||||||
|
$direct->setFileId($this->file->getId());
|
||||||
|
|
||||||
|
$token = $this->random->generate(60, ISecureRandom::CHAR_ALPHANUMERIC);
|
||||||
|
$direct->setToken($token);
|
||||||
|
$direct->setExpiration($this->timeFactory->getTime() + (60 * 60 * 8));
|
||||||
|
|
||||||
|
$this->mapper->insert($direct);
|
||||||
|
|
||||||
|
$url = $this->urlGenerator->getAbsoluteURL('remote.php/direct/' . $token);
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,17 @@ use OCA\BigBlueButton\NoPermissionException;
|
||||||
use OCA\BigBlueButton\NotFoundException;
|
use OCA\BigBlueButton\NotFoundException;
|
||||||
use OCA\BigBlueButton\Permission;
|
use OCA\BigBlueButton\Permission;
|
||||||
use OCA\BigBlueButton\Service\RoomService;
|
use OCA\BigBlueButton\Service\RoomService;
|
||||||
|
use OCA\DAV\Db\DirectMapper;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http\RedirectResponse;
|
use OCP\AppFramework\Http\RedirectResponse;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\BackgroundJob\IJobList;
|
use OCP\BackgroundJob\IJobList;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
|
use OCP\Security\ISecureRandom;
|
||||||
|
|
||||||
class JoinController extends Controller
|
class JoinController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -48,6 +51,15 @@ class JoinController extends Controller
|
||||||
/** @var IRootFolder */
|
/** @var IRootFolder */
|
||||||
private $iRootFolder;
|
private $iRootFolder;
|
||||||
|
|
||||||
|
/** @var DirectMapper */
|
||||||
|
private $mapper;
|
||||||
|
|
||||||
|
/** @var ISecureRandom */
|
||||||
|
private $random;
|
||||||
|
|
||||||
|
/** @var ITimeFactory */
|
||||||
|
private $timeFactory;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $appName,
|
string $appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
|
@ -57,7 +69,10 @@ class JoinController extends Controller
|
||||||
API $api,
|
API $api,
|
||||||
Permission $permission,
|
Permission $permission,
|
||||||
IJobList $jobList,
|
IJobList $jobList,
|
||||||
IRootFolder $iRootFolder
|
IRootFolder $iRootFolder,
|
||||||
|
DirectMapper $mapper,
|
||||||
|
ISecureRandom $random,
|
||||||
|
ITimeFactory $timeFactory
|
||||||
) {
|
) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
|
||||||
|
@ -68,6 +83,9 @@ class JoinController extends Controller
|
||||||
$this->permission = $permission;
|
$this->permission = $permission;
|
||||||
$this->jobList = $jobList;
|
$this->jobList = $jobList;
|
||||||
$this->iRootFolder = $iRootFolder;
|
$this->iRootFolder = $iRootFolder;
|
||||||
|
$this->mapper = $mapper;
|
||||||
|
$this->random = $random;
|
||||||
|
$this->timeFactory = $timeFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setToken(string $token): void
|
public function setToken(string $token): void
|
||||||
|
@ -118,11 +136,10 @@ class JoinController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->permission->isAdmin($room, $userId) && !empty($filename)) {
|
if ($this->permission->isAdmin($room, $userId) && !empty($filename)) {
|
||||||
$presentation = new Presentation($filename, $userId, $this->iRootFolder);
|
$presentation = new Presentation($filename, $userId, $this->iRootFolder, $this->mapper, $this->random, $this->timeFactory, $this->urlGenerator);
|
||||||
} else if (!$room->running && !empty($room->presentationPath)) {
|
} else if (!$room->running && !empty($room->presentationPath)) {
|
||||||
$presentation = new Presentation($room->presentationPath, $room->presentationUserId, $this->iRootFolder);
|
$presentation = new Presentation($room->presentationPath, $room->presentationUserId, $this->iRootFolder, $this->mapper, $this->random, $this->timeFactory, $this->urlGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($room->access === Room::ACCESS_INTERNAL || $room->access === Room::ACCESS_INTERNAL_RESTRICTED) {
|
} elseif ($room->access === Room::ACCESS_INTERNAL || $room->access === Room::ACCESS_INTERNAL_RESTRICTED) {
|
||||||
return new RedirectResponse($this->getLoginUrl());
|
return new RedirectResponse($this->getLoginUrl());
|
||||||
} elseif (empty($displayname) || strlen($displayname) < 3 || ($room->access === Room::ACCESS_PASSWORD && $password !== $room->password)) {
|
} elseif (empty($displayname) || strlen($displayname) < 3 || ($room->access === Room::ACCESS_PASSWORD && $password !== $room->password)) {
|
||||||
|
|
Loading…
Reference in New Issue