feat: default Presentation

fixed some formatting with cs-fixer
pull/207/head
Specht, David 2022-05-24 23:58:07 +02:00
parent 7f2372d207
commit e0bc1a2332
5 changed files with 23 additions and 43 deletions

View File

@ -8,12 +8,10 @@ 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\Folder;
use OCP\Files\Storage\IStorage;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
class Presentation class Presentation {
{
private $url; private $url;
private $userId; private $userId;
@ -53,8 +51,7 @@ class Presentation
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
} }
public function generateUrl() public function generateUrl() {
{
$direct = new Direct(); $direct = new Direct();
$direct->setUserId($this->userId); $direct->setUserId($this->userId);
$direct->setFileId($this->file->getId()); $direct->setFileId($this->file->getId());
@ -70,18 +67,15 @@ class Presentation
return $url; return $url;
} }
public function getUrl(): string public function getUrl(): string {
{
return $this->url; return $this->url;
} }
public function getFilename(): string public function getFilename(): string {
{
return $this->file->getName(); return $this->file->getName();
} }
public function isValid(): bool public function isValid(): bool {
{
return !empty($this->file->getContent()); return !empty($this->file->getContent());
} }
} }

View File

@ -22,8 +22,7 @@ use OCP\IURLGenerator;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
class JoinController extends Controller class JoinController extends Controller {
{
/** @var string */ /** @var string */
protected $token; protected $token;
@ -88,14 +87,12 @@ class JoinController extends Controller
$this->timeFactory = $timeFactory; $this->timeFactory = $timeFactory;
} }
public function setToken(string $token): void public function setToken(string $token): void {
{
$this->token = $token; $this->token = $token;
$this->room = null; $this->room = null;
} }
public function isValidToken(): bool public function isValidToken(): bool {
{
$room = $this->getRoom(); $room = $this->getRoom();
return $room !== null; return $room !== null;
@ -108,8 +105,7 @@ class JoinController extends Controller
* *
* @return RedirectResponse|TemplateResponse * @return RedirectResponse|TemplateResponse
*/ */
public function index($displayname, $u = '', $filename = '', $password = '') public function index($displayname, $u = '', $filename = '', $password = '') {
{
$room = $this->getRoom(); $room = $this->getRoom();
if ($room === null) { if ($room === null) {
@ -137,7 +133,7 @@ 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, $this->mapper, $this->random, $this->timeFactory, $this->urlGenerator); $presentation = new Presentation($filename, $userId, $this->iRootFolder, $this->mapper, $this->random, $this->timeFactory, $this->urlGenerator);
} else if (!$room->running && !empty($room->presentationPath)) { } elseif (!$room->running && !empty($room->presentationPath)) {
$presentation = new Presentation($room->presentationPath, $room->presentationUserId, $this->iRootFolder, $this->mapper, $this->random, $this->timeFactory, $this->urlGenerator); $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) {
@ -176,8 +172,7 @@ class JoinController extends Controller
], 'guest'); ], 'guest');
} }
private function getRoom(): ?Room private function getRoom(): ?Room {
{
if ($this->room === null) { if ($this->room === null) {
$this->room = $this->service->findByUid($this->token); $this->room = $this->service->findByUid($this->token);
} }
@ -185,8 +180,7 @@ class JoinController extends Controller
return $this->room; return $this->room;
} }
private function getLoginUrl(): string private function getLoginUrl(): string {
{
return $this->urlGenerator->linkToRoute('core.login.showLoginForm', [ return $this->urlGenerator->linkToRoute('core.login.showLoginForm', [
'redirect_url' => $this->urlGenerator->linkToRoute( 'redirect_url' => $this->urlGenerator->linkToRoute(
'bbb.join.index', 'bbb.join.index',
@ -195,8 +189,7 @@ class JoinController extends Controller
]); ]);
} }
private function markAsRunning(Room $room) private function markAsRunning(Room $room) {
{
if (!$room->running) { if (!$room->running) {
$this->service->updateRunning($room->getId(), true); $this->service->updateRunning($room->getId(), true);
} }

View File

@ -13,8 +13,8 @@ use OCP\IGroupManager;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUserManager; use OCP\IUserManager;
class RoomController extends Controller class RoomController extends Controller {
{ use Errors;
/** @var RoomService */ /** @var RoomService */
private $service; private $service;
@ -33,8 +33,6 @@ class RoomController extends Controller
/** @var string */ /** @var string */
private $userId; private $userId;
use Errors;
public function __construct( public function __construct(
$appName, $appName,
IRequest $request, IRequest $request,
@ -57,8 +55,7 @@ class RoomController extends Controller
/** /**
* @NoAdminRequired * @NoAdminRequired
*/ */
public function index(): DataResponse public function index(): DataResponse {
{
$user = $this->userManager->get($this->userId); $user = $this->userManager->get($this->userId);
$groupIds = $this->groupManager->getUserGroupIds($user); $groupIds = $this->groupManager->getUserGroupIds($user);
$circleIds = $this->circleHelper->getCircleIds($this->userId); $circleIds = $this->circleHelper->getCircleIds($this->userId);
@ -166,8 +163,7 @@ class RoomController extends Controller
/** /**
* @NoAdminRequired * @NoAdminRequired
*/ */
public function destroy(int $id): DataResponse public function destroy(int $id): DataResponse {
{
$room = $this->service->find($id); $room = $this->service->find($id);
if (!$this->permission->isAdmin($room, $this->userId)) { if (!$this->permission->isAdmin($room, $this->userId)) {

View File

@ -34,18 +34,14 @@ use OCP\Migration\SimpleMigrationStep;
/** /**
* Auto-generated migration step: Please modify to your needs! * Auto-generated migration step: Please modify to your needs!
*/ */
class Version000000Date20220413130357 extends SimpleMigrationStep class Version000000Date20220413130357 extends SimpleMigrationStep {
{
/** /**
* @param IOutput $output * @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
{
$schema = $schemaClosure(); $schema = $schemaClosure();
if ($schema->hasTable('bbb_rooms')) { if ($schema->hasTable('bbb_rooms')) {

View File

@ -16,7 +16,6 @@ use OCP\IConfig;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
class RoomService { class RoomService {
/** @var RoomMapper */ /** @var RoomMapper */
private $mapper; private $mapper;
@ -33,7 +32,8 @@ class RoomService {
RoomMapper $mapper, RoomMapper $mapper,
IConfig $config, IConfig $config,
IEventDispatcher $eventDispatcher, IEventDispatcher $eventDispatcher,
ISecureRandom $random) { ISecureRandom $random
) {
$this->mapper = $mapper; $this->mapper = $mapper;
$this->config = $config; $this->config = $config;
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
@ -137,7 +137,8 @@ class RoomService {
bool $cleanLayout, bool $cleanLayout,
bool $joinMuted, bool $joinMuted,
string $presentationUserId, string $presentationUserId,
string $presentationPath) { string $presentationPath
) {
try { try {
$room = $this->mapper->find($id); $room = $this->mapper->find($id);