feat: Default Presentation

get the direct download from the php api instead of frontend
pull/207/head
Specht, David 2022-05-10 15:35:59 +02:00
parent 38da9bda60
commit 9f0f591d7a
2 changed files with 36 additions and 25 deletions

View File

@ -2,37 +2,49 @@
namespace OCA\BigBlueButton\BigBlueButton;
use OCP\Files\IRootFolder;
use OCP\Files\File;
use OCP\Files\Storage\IStorage;
class Presentation {
class Presentation
{
private $url;
private $filename;
/** @var File*/
private $file;
private $path;
/** @var IRootFolder */
private $userFolder;
/** @var IStorage */
private $storage;
public function __construct(string $path, IStorage $storage) {
$this->storage = $storage;
$this->path = preg_replace('/^\//', '', $path);
$this->filename = preg_replace('/[^\x20-\x7E]+/','#', $path);
public function __construct(string $path, string $userID, IRootFolder $iRootFolder)
{
$userFolder = $iRootFolder->getUserFolder($userID);
$this->file = $userFolder->get($path);
$this->storage = $this->file->getStorage();
}
public function generateUrl(): string {
return $this->storage->getDirectDownload($this->path);
public function generateUrl(): string
{
$filePath = $this->file->getInternalPath();
[$url] = $this->storage->getDirectDownload($filePath);
return $url;
}
public function getUrl(): string {
public function getUrl(): string
{
return $this->url;
}
public function getFilename(): string {
return $this->filename;
public function getFilename(): string
{
return $this->file->getName();
}
public function isValid(): bool {
return !empty($this->filename);
public function isValid(): bool
{
return !empty($this->file->getContent());
}
}

View File

@ -14,7 +14,7 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\BackgroundJob\IJobList;
use OCP\Files\Storage\IStorage;
use OCP\Files\IRootFolder;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserSession;
@ -45,8 +45,8 @@ class JoinController extends Controller
/** @var IJobList */
private $jobList;
/** @var IStorage */
private $storage;
/** @var IRootFolder */
private $iRootFolder;
public function __construct(
string $appName,
@ -57,7 +57,7 @@ class JoinController extends Controller
API $api,
Permission $permission,
IJobList $jobList,
IStorage $storage
IRootFolder $iRootFolder
) {
parent::__construct($appName, $request);
@ -67,7 +67,7 @@ class JoinController extends Controller
$this->api = $api;
$this->permission = $permission;
$this->jobList = $jobList;
$this->storage = $storage;
$this->iRootFolder = $iRootFolder;
}
public function setToken(string $token): void
@ -117,13 +117,12 @@ class JoinController extends Controller
throw new NoPermissionException();
}
if ($this->permission->isAdmin($room, $userId)) {
$presentation = new Presentation($filename, $this->storage);
}
if (!$room->running && $presentation === null) {
$presentation = new Presentation($room->presentationPath, $this->storage);
if ($this->permission->isAdmin($room, $userId) && !empty($filename)) {
$presentation = new Presentation($filename, $userId, $this->iRootFolder);
} else if (!$room->running && !empty($room->presentationPath)) {
$presentation = new Presentation($room->presentationPath, $room->presentationUserId, $this->iRootFolder);
}
} elseif ($room->access === Room::ACCESS_INTERNAL || $room->access === Room::ACCESS_INTERNAL_RESTRICTED) {
return new RedirectResponse($this->getLoginUrl());
} elseif (empty($displayname) || strlen($displayname) < 3 || ($room->access === Room::ACCESS_PASSWORD && $password !== $room->password)) {