mirror of https://github.com/sualko/cloud_bbb
refactor: use Nextcloud coding standard
parent
da9234a24f
commit
86415b3f6a
29
.php_cs.dist
29
.php_cs.dist
|
@ -1,13 +1,18 @@
|
|||
<?php
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in('lib/')
|
||||
;
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => false],
|
||||
])
|
||||
->setIndent("\t")
|
||||
->setFinder($finder)
|
||||
;
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once './vendor/autoload.php';
|
||||
|
||||
use Nextcloud\CodingStandard\Config;
|
||||
|
||||
$config = new Config();
|
||||
$config
|
||||
->getFinder()
|
||||
->ignoreVCSIgnored(true)
|
||||
->notPath('build')
|
||||
->notPath('l10n')
|
||||
->notPath('src')
|
||||
->notPath('vendor')
|
||||
->in(__DIR__);
|
||||
return $config;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
OCP\Util::addScript ( 'bbb', 'filelist');
|
||||
OCP\Util::addScript('bbb', 'filelist');
|
||||
|
||||
$apiUrl = \OC::$server->getConfig()->getAppValue('bbb', 'api.url');
|
||||
$parsedApiUrl = @parse_url($apiUrl);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'resources' => [
|
||||
'room' => ['url' => '/rooms'],
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8",
|
||||
"friendsofphp/php-cs-fixer": "^2.16"
|
||||
"friendsofphp/php-cs-fixer": "^2.16",
|
||||
"nextcloud/coding-standard": "^0.3.0"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "67b538bdf36cbd6464297b3d9257bb3c",
|
||||
"content-hash": "a5f7d2fab7db00ef99eb9468c2fa9a0a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "littleredbutton/bigbluebutton-api-php",
|
||||
|
@ -580,6 +580,43 @@
|
|||
],
|
||||
"time": "2020-01-17T21:11:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nextcloud/coding-standard",
|
||||
"version": "v0.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nextcloud/coding-standard.git",
|
||||
"reference": "4f5cd012760f8293e19e602651a0ecaa265e4db9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/4f5cd012760f8293e19e602651a0ecaa265e4db9",
|
||||
"reference": "4f5cd012760f8293e19e602651a0ecaa265e4db9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"friendsofphp/php-cs-fixer": "^2.16",
|
||||
"php": "^7.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Nextcloud\\CodingStandard\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christoph Wurst",
|
||||
"email": "christoph@winzerhof-wurst.at"
|
||||
}
|
||||
],
|
||||
"description": "Nextcloud coding standards for the php cs fixer",
|
||||
"time": "2020-04-10T14:57:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/random_compat",
|
||||
"version": "v9.99.99",
|
||||
|
|
|
@ -9,10 +9,8 @@ if ((@include_once __DIR__ . '/../../vendor/autoload.php') === false) {
|
|||
throw new \Exception('Cannot include autoload. Did you run install dependencies using composer?');
|
||||
}
|
||||
|
||||
class Application extends App
|
||||
{
|
||||
public function __construct(array $urlParams = [])
|
||||
{
|
||||
class Application extends App {
|
||||
public function __construct(array $urlParams = []) {
|
||||
parent::__construct('bbb', $urlParams);
|
||||
|
||||
$container = $this->getContainer();
|
||||
|
|
|
@ -10,15 +10,11 @@ use BigBlueButton\Core\Record;
|
|||
use BigBlueButton\Parameters\DeleteRecordingsParameters;
|
||||
use BigBlueButton\Parameters\IsMeetingRunningParameters;
|
||||
use OCA\BigBlueButton\Db\Room;
|
||||
use OCA\BigBlueButton\Db\RoomShare;
|
||||
use OCA\BigBlueButton\Permission;
|
||||
use OCA\BigBlueButton\Service\RoomShareService;
|
||||
use OCP\IConfig;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IGroupManager;
|
||||
|
||||
class API
|
||||
{
|
||||
class API {
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
|
@ -41,8 +37,7 @@ class API
|
|||
$this->permission = $permission;
|
||||
}
|
||||
|
||||
private function getServer()
|
||||
{
|
||||
private function getServer() {
|
||||
if (!$this->server) {
|
||||
$apiUrl = $this->config->getAppValue('bbb', 'api.url');
|
||||
$secret = $this->config->getAppValue('bbb', 'api.secret');
|
||||
|
@ -58,8 +53,7 @@ class API
|
|||
*
|
||||
* @return string join url
|
||||
*/
|
||||
public function createJoinUrl(Room $room, int $creationTime, string $displayname, ?string $uid = null)
|
||||
{
|
||||
public function createJoinUrl(Room $room, int $creationTime, string $displayname, ?string $uid = null) {
|
||||
$password = $this->permission->isModerator($room, $uid) ? $room->moderatorPassword : $room->attendeePassword;
|
||||
|
||||
$joinMeetingParams = new JoinMeetingParameters($room->uid, $displayname, $password);
|
||||
|
@ -82,8 +76,7 @@ class API
|
|||
*
|
||||
* @return int creation time
|
||||
*/
|
||||
public function createMeeting(Room $room, Presentation $presentation = null)
|
||||
{
|
||||
public function createMeeting(Room $room, Presentation $presentation = null) {
|
||||
$bbb = $this->getServer();
|
||||
$meetingParams = $this->buildMeetingParams($room, $presentation);
|
||||
|
||||
|
@ -100,8 +93,7 @@ class API
|
|||
return $response->getCreationTime();
|
||||
}
|
||||
|
||||
private function buildMeetingParams(Room $room, Presentation $presentation = null): CreateMeetingParameters
|
||||
{
|
||||
private function buildMeetingParams(Room $room, Presentation $presentation = null): CreateMeetingParameters {
|
||||
$createMeetingParams = new CreateMeetingParameters($room->uid, $room->name);
|
||||
$createMeetingParams->setAttendeePassword($room->attendeePassword);
|
||||
$createMeetingParams->setModeratorPassword($room->moderatorPassword);
|
||||
|
@ -131,8 +123,7 @@ class API
|
|||
return $createMeetingParams;
|
||||
}
|
||||
|
||||
public function getRecording(string $recordId)
|
||||
{
|
||||
public function getRecording(string $recordId) {
|
||||
$recordingParams = new GetRecordingsParameters();
|
||||
$recordingParams->setRecordId($recordId);
|
||||
$recordingParams->setState('any');
|
||||
|
@ -152,8 +143,7 @@ class API
|
|||
return $this->recordToArray($records[0]);
|
||||
}
|
||||
|
||||
public function getRecordings(Room $room)
|
||||
{
|
||||
public function getRecordings(Room $room) {
|
||||
$recordingParams = new GetRecordingsParameters();
|
||||
$recordingParams->setMeetingId($room->uid);
|
||||
$recordingParams->setState('processing,processed,published,unpublished');
|
||||
|
@ -171,8 +161,7 @@ class API
|
|||
}, $records);
|
||||
}
|
||||
|
||||
public function deleteRecording(string $recordingId): bool
|
||||
{
|
||||
public function deleteRecording(string $recordingId): bool {
|
||||
$deleteParams = new DeleteRecordingsParameters($recordingId);
|
||||
|
||||
$response = $this->getServer()->deleteRecordings($deleteParams);
|
||||
|
@ -180,8 +169,7 @@ class API
|
|||
return $response->isDeleted();
|
||||
}
|
||||
|
||||
private function recordToArray(Record $record)
|
||||
{
|
||||
private function recordToArray(Record $record) {
|
||||
return [
|
||||
'id' => $record->getRecordId(),
|
||||
'name' => $record->getName(),
|
||||
|
@ -196,8 +184,7 @@ class API
|
|||
];
|
||||
}
|
||||
|
||||
public function check($url, $secret)
|
||||
{
|
||||
public function check($url, $secret) {
|
||||
$server = new BigBlueButton($url, $secret);
|
||||
|
||||
$meetingParams = new IsMeetingRunningParameters('foobar');
|
||||
|
@ -219,8 +206,7 @@ class API
|
|||
}
|
||||
}
|
||||
|
||||
public function getVersion($url = null)
|
||||
{
|
||||
public function getVersion($url = null) {
|
||||
$server = $url === null ? $this->getServer() : new BigBlueButton($url, '');
|
||||
|
||||
return $server->getApiVersion()->getVersion();
|
||||
|
|
|
@ -2,30 +2,25 @@
|
|||
|
||||
namespace OCA\BigBlueButton\BigBlueButton;
|
||||
|
||||
class Presentation
|
||||
{
|
||||
class Presentation {
|
||||
private $url;
|
||||
|
||||
private $filename;
|
||||
|
||||
public function __construct(string $url, string $filename)
|
||||
{
|
||||
public function __construct(string $url, string $filename) {
|
||||
$this->url = $url;
|
||||
$this->filename = $filename;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
public function getUrl() {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
public function getFilename() {
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
public function isValid()
|
||||
{
|
||||
public function isValid() {
|
||||
return !empty($this->url) && !empty($this->filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,8 @@ use OCP\AppFramework\Http\DataResponse;
|
|||
use OCA\BigBlueButton\Service\RoomNotFound;
|
||||
use OCA\BigBlueButton\Service\RoomShareNotFound;
|
||||
|
||||
trait Errors
|
||||
{
|
||||
protected function handleNotFound(Closure $callback): DataResponse
|
||||
{
|
||||
trait Errors {
|
||||
protected function handleNotFound(Closure $callback): DataResponse {
|
||||
try {
|
||||
$return = $callback();
|
||||
return ($return instanceof DataResponse) ? $return : new DataResponse($return);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Controller;
|
||||
|
||||
use OCA\BigBlueButton\BigBlueButton\API;
|
||||
|
@ -17,8 +18,7 @@ use OCA\BigBlueButton\Service\RoomService;
|
|||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
||||
class JoinController extends Controller
|
||||
{
|
||||
class JoinController extends Controller {
|
||||
/** @var string */
|
||||
protected $token;
|
||||
|
||||
|
@ -64,14 +64,12 @@ class JoinController extends Controller
|
|||
$this->permission = $permission;
|
||||
}
|
||||
|
||||
public function setToken(string $token)
|
||||
{
|
||||
public function setToken(string $token) {
|
||||
$this->token = $token;
|
||||
$this->room = null;
|
||||
}
|
||||
|
||||
public function isValidToken(): bool
|
||||
{
|
||||
public function isValidToken(): bool {
|
||||
$room = $this->getRoom();
|
||||
|
||||
return $room !== null;
|
||||
|
@ -81,8 +79,7 @@ class JoinController extends Controller
|
|||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function index($displayname, $u = '', $filename = '', $password = '')
|
||||
{
|
||||
public function index($displayname, $u = '', $filename = '', $password = '') {
|
||||
$room = $this->getRoom();
|
||||
|
||||
if ($room === null) {
|
||||
|
@ -133,8 +130,7 @@ class JoinController extends Controller
|
|||
return new RedirectResponse($joinUrl);
|
||||
}
|
||||
|
||||
private function addFormActionDomain($response)
|
||||
{
|
||||
private function addFormActionDomain($response) {
|
||||
$apiUrl = $this->config->getAppValue($this->appName, 'api.url');
|
||||
$parsedApiUrl = parse_url($apiUrl);
|
||||
|
||||
|
@ -145,8 +141,7 @@ class JoinController extends Controller
|
|||
$response->getContentSecurityPolicy()->addAllowedFormActionDomain(($parsedApiUrl['scheme'] ?: 'https') . '://' . $parsedApiUrl['host']);
|
||||
}
|
||||
|
||||
private function getRoom(): ?Room
|
||||
{
|
||||
private function getRoom(): ?Room {
|
||||
if ($this->room === null) {
|
||||
$this->room = $this->service->findByUid($this->token);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@ use OCP\AppFramework\Controller;
|
|||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
|
||||
class RoomController extends Controller
|
||||
{
|
||||
class RoomController extends Controller {
|
||||
/** @var RoomService */
|
||||
private $service;
|
||||
|
||||
|
@ -50,8 +49,7 @@ class RoomController extends Controller
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function index(): DataResponse
|
||||
{
|
||||
public function index(): DataResponse {
|
||||
$user = $this->userManager->get($this->userId);
|
||||
$groupIds = $this->groupManager->getUserGroupIds($user);
|
||||
|
||||
|
@ -102,8 +100,7 @@ class RoomController extends Controller
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function destroy(int $id): DataResponse
|
||||
{
|
||||
public function destroy(int $id): DataResponse {
|
||||
$room = $this->service->find($id);
|
||||
|
||||
if (!$this->permission->isAdmin($room, $this->userId)) {
|
||||
|
|
|
@ -13,8 +13,7 @@ use OCP\AppFramework\Controller;
|
|||
use OCA\BigBlueButton\Service\RoomShareService;
|
||||
use OCP\IUserManager;
|
||||
|
||||
class RoomShareController extends Controller
|
||||
{
|
||||
class RoomShareController extends Controller {
|
||||
/** @var RoomShareService */
|
||||
private $service;
|
||||
|
||||
|
@ -47,8 +46,7 @@ class RoomShareController extends Controller
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function index(): DataResponse
|
||||
{
|
||||
public function index(): DataResponse {
|
||||
$roomId = $this->request->getParam('id');
|
||||
|
||||
if ($roomId === null) {
|
||||
|
@ -127,8 +125,7 @@ class RoomShareController extends Controller
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function destroy(int $id): DataResponse
|
||||
{
|
||||
public function destroy(int $id): DataResponse {
|
||||
return $this->handleNotFound(function () use ($id) {
|
||||
$roomShare = $this->service->find($id);
|
||||
|
||||
|
@ -140,8 +137,7 @@ class RoomShareController extends Controller
|
|||
});
|
||||
}
|
||||
|
||||
private function isUserAllowed(int $roomId): bool
|
||||
{
|
||||
private function isUserAllowed(int $roomId): bool {
|
||||
try {
|
||||
$room = $this->roomService->find($roomId);
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@ use OCP\AppFramework\Controller;
|
|||
|
||||
use OCA\BigBlueButton\Service\RoomService;
|
||||
|
||||
class ServerController extends Controller
|
||||
{
|
||||
class ServerController extends Controller {
|
||||
/** @var RoomService */
|
||||
private $service;
|
||||
|
||||
|
@ -44,8 +43,7 @@ class ServerController extends Controller
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function records(string $roomUid): DataResponse
|
||||
{
|
||||
public function records(string $roomUid): DataResponse {
|
||||
$room = $this->service->findByUid($roomUid);
|
||||
|
||||
if ($room === null) {
|
||||
|
@ -64,8 +62,7 @@ class ServerController extends Controller
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function deleteRecord(string $recordId): DataResponse
|
||||
{
|
||||
public function deleteRecord(string $recordId): DataResponse {
|
||||
$record = $this->server->getRecording($recordId);
|
||||
|
||||
$room = $this->service->findByUid($record['metas']['meetingId']);
|
||||
|
@ -83,8 +80,7 @@ class ServerController extends Controller
|
|||
return new DataResponse($success);
|
||||
}
|
||||
|
||||
public function check(string $url, string $secret)
|
||||
{
|
||||
public function check(string $url, string $secret) {
|
||||
if ($url === null || empty($url) || $secret === null || empty($secret)) {
|
||||
return new DataResponse(false);
|
||||
}
|
||||
|
@ -92,8 +88,7 @@ class ServerController extends Controller
|
|||
return new DataResponse($this->server->check($url, $secret));
|
||||
}
|
||||
|
||||
public function version(string $url)
|
||||
{
|
||||
public function version(string $url) {
|
||||
if ($url === null || empty($url)) {
|
||||
return new DataResponse(false, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Db;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class Room extends Entity implements JsonSerializable
|
||||
{
|
||||
const ACCESS_PUBLIC = 'public';
|
||||
const ACCESS_PASSWORD = 'password';
|
||||
const ACCESS_WAITING_ROOM = 'waiting_room';
|
||||
const ACCESS_INTERNAL = 'internal';
|
||||
const ACCESS_INTERNAL_RESTRICTED = 'internal_restricted';
|
||||
class Room extends Entity implements JsonSerializable {
|
||||
public const ACCESS_PUBLIC = 'public';
|
||||
public const ACCESS_PASSWORD = 'password';
|
||||
public const ACCESS_WAITING_ROOM = 'waiting_room';
|
||||
public const ACCESS_INTERNAL = 'internal';
|
||||
public const ACCESS_INTERNAL_RESTRICTED = 'internal_restricted';
|
||||
|
||||
public $uid;
|
||||
public $name;
|
||||
|
@ -25,15 +25,13 @@ class Room extends Entity implements JsonSerializable
|
|||
public $password;
|
||||
public $everyoneIsModerator;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$this->addType('maxParticipants', 'integer');
|
||||
$this->addType('record', 'boolean');
|
||||
$this->addType('everyoneIsModerator', 'boolean');
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uid' => $this->uid,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Db;
|
||||
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
@ -7,10 +8,8 @@ use OCP\AppFramework\Db\QBMapper;
|
|||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
class RoomMapper extends QBMapper
|
||||
{
|
||||
public function __construct(IDBConnection $db)
|
||||
{
|
||||
class RoomMapper extends QBMapper {
|
||||
public function __construct(IDBConnection $db) {
|
||||
parent::__construct($db, 'bbb_rooms', Room::class);
|
||||
}
|
||||
|
||||
|
@ -21,8 +20,7 @@ class RoomMapper extends QBMapper
|
|||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
public function find(int $id): Room
|
||||
{
|
||||
public function find(int $id): Room {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
|
@ -37,8 +35,7 @@ class RoomMapper extends QBMapper
|
|||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
public function findByUid(string $uid): Room
|
||||
{
|
||||
public function findByUid(string $uid): Room {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
|
@ -52,8 +49,7 @@ class RoomMapper extends QBMapper
|
|||
* @param array $groupIds
|
||||
* @return array
|
||||
*/
|
||||
public function findAll(string $userId, array $groupIds): array
|
||||
{
|
||||
public function findAll(string $userId, array $groupIds): array {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('r.*')
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Db;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class RoomShare extends Entity implements JsonSerializable
|
||||
{
|
||||
const PERMISSION_ADMIN = 0;
|
||||
const PERMISSION_MODERATOR = 1;
|
||||
const PERMISSION_USER = 2;
|
||||
class RoomShare extends Entity implements JsonSerializable {
|
||||
public const PERMISSION_ADMIN = 0;
|
||||
public const PERMISSION_MODERATOR = 1;
|
||||
public const PERMISSION_USER = 2;
|
||||
|
||||
const SHARE_TYPE_USER = 0;
|
||||
const SHARE_TYPE_GROUP = 1;
|
||||
public const SHARE_TYPE_USER = 0;
|
||||
public const SHARE_TYPE_GROUP = 1;
|
||||
|
||||
protected $roomId;
|
||||
protected $shareType;
|
||||
|
@ -20,15 +20,13 @@ class RoomShare extends Entity implements JsonSerializable
|
|||
protected $shareWithDisplayName;
|
||||
protected $permission;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$this->addType('roomId', 'integer');
|
||||
$this->addType('shareType', 'integer');
|
||||
$this->addType('permission', 'integer');
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'roomId' => $this->roomId,
|
||||
|
@ -39,18 +37,15 @@ class RoomShare extends Entity implements JsonSerializable
|
|||
];
|
||||
}
|
||||
|
||||
public function hasUserPermission(): bool
|
||||
{
|
||||
public function hasUserPermission(): bool {
|
||||
return $this->permission === self::PERMISSION_ADMIN || $this->permission === self::PERMISSION_MODERATOR || $this->permission === self::PERMISSION_USER;
|
||||
}
|
||||
|
||||
public function hasModeratorPermission(): bool
|
||||
{
|
||||
public function hasModeratorPermission(): bool {
|
||||
return $this->permission === self::PERMISSION_ADMIN || $this->permission === self::PERMISSION_MODERATOR;
|
||||
}
|
||||
|
||||
public function hasAdminPermission(): bool
|
||||
{
|
||||
public function hasAdminPermission(): bool {
|
||||
return $this->permission === self::PERMISSION_ADMIN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Db;
|
||||
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
@ -7,10 +8,8 @@ use OCP\AppFramework\Db\QBMapper;
|
|||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
class RoomShareMapper extends QBMapper
|
||||
{
|
||||
public function __construct(IDBConnection $db)
|
||||
{
|
||||
class RoomShareMapper extends QBMapper {
|
||||
public function __construct(IDBConnection $db) {
|
||||
parent::__construct($db, 'bbb_room_shares', RoomShare::class);
|
||||
}
|
||||
|
||||
|
@ -20,8 +19,7 @@ class RoomShareMapper extends QBMapper
|
|||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
public function find(int $id): RoomShare
|
||||
{
|
||||
public function find(int $id): RoomShare {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
|
@ -30,8 +28,7 @@ class RoomShareMapper extends QBMapper
|
|||
return $this->findEntity($qb);
|
||||
}
|
||||
|
||||
public function findByRoomAndEntity(int $roomId, string $shareWith, int $shareType): RoomShare
|
||||
{
|
||||
public function findByRoomAndEntity(int $roomId, string $shareWith, int $shareType): RoomShare {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
|
@ -43,8 +40,7 @@ class RoomShareMapper extends QBMapper
|
|||
return $this->findEntity($qb);
|
||||
}
|
||||
|
||||
public function findAll(int $roomId): array
|
||||
{
|
||||
public function findAll(int $roomId): array {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Middleware;
|
||||
|
||||
use OCA\BigBlueButton\Controller\JoinController;
|
||||
|
@ -9,18 +10,15 @@ use OCP\AppFramework\Middleware;
|
|||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
use OCP\IRequest;
|
||||
|
||||
class JoinMiddleware extends Middleware
|
||||
{
|
||||
class JoinMiddleware extends Middleware {
|
||||
/** @var IRequest */
|
||||
private $request;
|
||||
|
||||
public function __construct(IRequest $request)
|
||||
{
|
||||
public function __construct(IRequest $request) {
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function beforeController($controller, $methodName)
|
||||
{
|
||||
public function beforeController($controller, $methodName) {
|
||||
if (!($controller instanceof JoinController)) {
|
||||
return;
|
||||
}
|
||||
|
@ -39,8 +37,7 @@ class JoinMiddleware extends Middleware
|
|||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
public function afterException($controller, $methodName, \Exception $exception)
|
||||
{
|
||||
public function afterException($controller, $methodName, \Exception $exception) {
|
||||
if (!($controller instanceof JoinController)) {
|
||||
throw $exception;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@ use OCP\DB\ISchemaWrapper;
|
|||
use OCP\Migration\SimpleMigrationStep;
|
||||
use OCP\Migration\IOutput;
|
||||
|
||||
class Version000000Date20200416124731 extends SimpleMigrationStep
|
||||
{
|
||||
class Version000000Date20200416124731 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
|
@ -18,8 +17,7 @@ class Version000000Date20200416124731 extends SimpleMigrationStep
|
|||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options)
|
||||
{
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
|
|
|
@ -13,16 +13,14 @@ use OCP\Migration\SimpleMigrationStep;
|
|||
/**
|
||||
* Auto-generated migration step: Please modify to your needs!
|
||||
*/
|
||||
class Version000000Date20200604130935 extends SimpleMigrationStep
|
||||
{
|
||||
class Version000000Date20200604130935 extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options)
|
||||
{
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ use OCP\DB\ISchemaWrapper;
|
|||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
class Version000000Date20200613111242 extends SimpleMigrationStep
|
||||
{
|
||||
class Version000000Date20200613111242 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
|
@ -18,8 +17,7 @@ class Version000000Date20200613111242 extends SimpleMigrationStep
|
|||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options)
|
||||
{
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ use OCP\DB\ISchemaWrapper;
|
|||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
class Version000000Date20200617055735 extends SimpleMigrationStep
|
||||
{
|
||||
class Version000000Date20200617055735 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
|
@ -18,8 +17,7 @@ class Version000000Date20200617055735 extends SimpleMigrationStep
|
|||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options)
|
||||
{
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
|
|
|
@ -2,6 +2,5 @@
|
|||
|
||||
namespace OCA\BigBlueButton;
|
||||
|
||||
class NoPermissionException extends \Exception
|
||||
{
|
||||
class NoPermissionException extends \Exception {
|
||||
}
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton;
|
||||
|
||||
use OCP\Template;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
|
||||
class NoPermissionResponse extends Response
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
class NoPermissionResponse extends Response {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
$this->setContentSecurityPolicy(new ContentSecurityPolicy());
|
||||
$this->setStatus(404);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
public function render() {
|
||||
$template = new Template('core', '403', 'guest');
|
||||
return $template->fetchPage();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,5 @@
|
|||
|
||||
namespace OCA\BigBlueButton;
|
||||
|
||||
class NotFoundException extends \Exception
|
||||
{
|
||||
class NotFoundException extends \Exception {
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@ use OCA\BigBlueButton\Db\Room;
|
|||
use OCA\BigBlueButton\Db\RoomShare;
|
||||
use OCP\IGroupManager;
|
||||
|
||||
class Permission
|
||||
{
|
||||
class Permission {
|
||||
|
||||
/** @var IGroupManager */
|
||||
private $groupManager;
|
||||
|
@ -25,15 +24,13 @@ class Permission
|
|||
$this->roomShareService = $roomShareService;
|
||||
}
|
||||
|
||||
public function isUser(Room $room, ?string $uid)
|
||||
{
|
||||
public function isUser(Room $room, ?string $uid) {
|
||||
return $this->hasPermission($room, $uid, function (RoomShare $share) {
|
||||
return $share->hasUserPermission();
|
||||
});
|
||||
}
|
||||
|
||||
public function isModerator(Room $room, ?string $uid)
|
||||
{
|
||||
public function isModerator(Room $room, ?string $uid) {
|
||||
if ($room->everyoneIsModerator) {
|
||||
return true;
|
||||
}
|
||||
|
@ -43,15 +40,13 @@ class Permission
|
|||
});
|
||||
}
|
||||
|
||||
public function isAdmin(Room $room, ?string $uid)
|
||||
{
|
||||
public function isAdmin(Room $room, ?string $uid) {
|
||||
return $this->hasPermission($room, $uid, function (RoomShare $share) {
|
||||
return $share->hasAdminPermission();
|
||||
});
|
||||
}
|
||||
|
||||
private function hasPermission(Room $room, ?string $uid, Closure $hasPermission): bool
|
||||
{
|
||||
private function hasPermission(Room $room, ?string $uid, Closure $hasPermission): bool {
|
||||
if ($uid === null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,5 @@
|
|||
|
||||
namespace OCA\BigBlueButton\Service;
|
||||
|
||||
class RoomNotFound extends \Exception
|
||||
{
|
||||
class RoomNotFound extends \Exception {
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Service;
|
||||
|
||||
use Exception;
|
||||
|
@ -8,26 +9,21 @@ use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
|||
|
||||
use OCA\BigBlueButton\Db\Room;
|
||||
use OCA\BigBlueButton\Db\RoomMapper;
|
||||
use OCA\BigBlueButton\NoPermissionException;
|
||||
|
||||
class RoomService
|
||||
{
|
||||
class RoomService {
|
||||
|
||||
/** @var RoomMapper */
|
||||
private $mapper;
|
||||
|
||||
public function __construct(RoomMapper $mapper)
|
||||
{
|
||||
public function __construct(RoomMapper $mapper) {
|
||||
$this->mapper = $mapper;
|
||||
}
|
||||
|
||||
public function findAll(string $userId, array $groupIds): array
|
||||
{
|
||||
public function findAll(string $userId, array $groupIds): array {
|
||||
return $this->mapper->findAll($userId, $groupIds);
|
||||
}
|
||||
|
||||
private function handleException(Exception $e): void
|
||||
{
|
||||
private function handleException(Exception $e): void {
|
||||
if ($e instanceof DoesNotExistException ||
|
||||
$e instanceof MultipleObjectsReturnedException) {
|
||||
throw new RoomNotFound($e->getMessage());
|
||||
|
@ -36,8 +32,7 @@ class RoomService
|
|||
}
|
||||
}
|
||||
|
||||
public function find($id): Room
|
||||
{
|
||||
public function find($id): Room {
|
||||
try {
|
||||
return $this->mapper->find($id);
|
||||
|
||||
|
@ -50,8 +45,7 @@ class RoomService
|
|||
}
|
||||
}
|
||||
|
||||
public function findByUid($uid)
|
||||
{
|
||||
public function findByUid($uid) {
|
||||
try {
|
||||
return $this->mapper->findByUid($uid);
|
||||
} catch (Exception $e) {
|
||||
|
@ -60,8 +54,7 @@ class RoomService
|
|||
}
|
||||
}
|
||||
|
||||
public function create($name, $welcome, $maxParticipants, $record, $userId)
|
||||
{
|
||||
public function create($name, $welcome, $maxParticipants, $record, $userId) {
|
||||
$room = new Room();
|
||||
|
||||
$room->setUid(\OC::$server->getSecureRandom()->generate(16, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE));
|
||||
|
@ -76,8 +69,7 @@ class RoomService
|
|||
return $this->mapper->insert($room);
|
||||
}
|
||||
|
||||
public function update($id, $name, $welcome, $maxParticipants, $record, $access, $everyoneIsModerator)
|
||||
{
|
||||
public function update($id, $name, $welcome, $maxParticipants, $record, $access, $everyoneIsModerator) {
|
||||
try {
|
||||
$room = $this->mapper->find($id);
|
||||
|
||||
|
@ -98,8 +90,7 @@ class RoomService
|
|||
}
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
public function delete($id) {
|
||||
try {
|
||||
$room = $this->mapper->find($id);
|
||||
$this->mapper->delete($room);
|
||||
|
@ -109,8 +100,7 @@ class RoomService
|
|||
}
|
||||
}
|
||||
|
||||
private function humanReadableRandom($length)
|
||||
{
|
||||
private function humanReadableRandom($length) {
|
||||
return \OC::$server->getSecureRandom()->generate($length, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,5 @@
|
|||
|
||||
namespace OCA\BigBlueButton\Service;
|
||||
|
||||
class RoomShareNotFound extends \Exception
|
||||
{
|
||||
class RoomShareNotFound extends \Exception {
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Service;
|
||||
|
||||
use Exception;
|
||||
|
@ -9,24 +10,20 @@ use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
|||
use OCA\BigBlueButton\Db\RoomShare;
|
||||
use OCA\BigBlueButton\Db\RoomShareMapper;
|
||||
|
||||
class RoomShareService
|
||||
{
|
||||
class RoomShareService {
|
||||
|
||||
/** @var RoomShareMapper */
|
||||
private $mapper;
|
||||
|
||||
public function __construct(RoomShareMapper $mapper)
|
||||
{
|
||||
public function __construct(RoomShareMapper $mapper) {
|
||||
$this->mapper = $mapper;
|
||||
}
|
||||
|
||||
public function findAll(int $roomId): array
|
||||
{
|
||||
public function findAll(int $roomId): array {
|
||||
return $this->mapper->findAll($roomId);
|
||||
}
|
||||
|
||||
private function handleException(Exception $e): void
|
||||
{
|
||||
private function handleException(Exception $e): void {
|
||||
if ($e instanceof DoesNotExistException ||
|
||||
$e instanceof MultipleObjectsReturnedException) {
|
||||
throw new RoomShareNotFound($e->getMessage());
|
||||
|
@ -35,8 +32,7 @@ class RoomShareService
|
|||
}
|
||||
}
|
||||
|
||||
public function find($id): RoomShare
|
||||
{
|
||||
public function find($id): RoomShare {
|
||||
try {
|
||||
return $this->mapper->find($id);
|
||||
} catch (Exception $e) {
|
||||
|
@ -44,8 +40,7 @@ class RoomShareService
|
|||
}
|
||||
}
|
||||
|
||||
public function create(int $roomId, int $shareType, string $shareWith, int $permission): RoomShare
|
||||
{
|
||||
public function create(int $roomId, int $shareType, string $shareWith, int $permission): RoomShare {
|
||||
try {
|
||||
$roomShare = $this->mapper->findByRoomAndEntity($roomId, $shareWith, $shareType);
|
||||
|
||||
|
@ -62,8 +57,7 @@ class RoomShareService
|
|||
}
|
||||
}
|
||||
|
||||
public function update(int $id, int $roomId, int $shareType, string $shareWith, int $permission): RoomShare
|
||||
{
|
||||
public function update(int $id, int $roomId, int $shareType, string $shareWith, int $permission): RoomShare {
|
||||
try {
|
||||
$roomShare = $this->mapper->find($id);
|
||||
|
||||
|
@ -78,8 +72,7 @@ class RoomShareService
|
|||
}
|
||||
}
|
||||
|
||||
public function delete(int $id): RoomShare
|
||||
{
|
||||
public function delete(int $id): RoomShare {
|
||||
try {
|
||||
$roomShare = $this->mapper->find($id);
|
||||
$this->mapper->delete($roomShare);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Settings;
|
||||
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IConfig;
|
||||
use OCP\Settings\ISettings;
|
||||
|
||||
class Admin implements ISettings
|
||||
{
|
||||
class Admin implements ISettings {
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
@ -16,16 +16,14 @@ class Admin implements ISettings
|
|||
*
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(IConfig $config)
|
||||
{
|
||||
public function __construct(IConfig $config) {
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm()
|
||||
{
|
||||
public function getForm() {
|
||||
$parameters = [
|
||||
'api.url' => $this->config->getAppValue('bbb', 'api.url'),
|
||||
'api.secret' => $this->config->getAppValue('bbb', 'api.secret'),
|
||||
|
@ -37,8 +35,7 @@ class Admin implements ISettings
|
|||
/**
|
||||
* @return string the section ID, e.g. 'sharing'
|
||||
*/
|
||||
public function getSection()
|
||||
{
|
||||
public function getSection() {
|
||||
return 'additional';
|
||||
}
|
||||
|
||||
|
@ -47,8 +44,7 @@ class Admin implements ISettings
|
|||
* the admin section. The forms are arranged in ascending order of the
|
||||
* priority values. It is required to return a value between 0 and 100.
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
public function getPriority() {
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,7 @@ use OCP\Settings\ISettings;
|
|||
use OCP\IConfig;
|
||||
use \OCP\IL10N;
|
||||
|
||||
class Personal implements ISettings
|
||||
{
|
||||
class Personal implements ISettings {
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
|
@ -20,8 +19,7 @@ class Personal implements ISettings
|
|||
*
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(IConfig $config, IL10N $l)
|
||||
{
|
||||
public function __construct(IConfig $config, IL10N $l) {
|
||||
$this->config = $config;
|
||||
$this->l = $l;
|
||||
}
|
||||
|
@ -29,8 +27,7 @@ class Personal implements ISettings
|
|||
/**
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm()
|
||||
{
|
||||
public function getForm() {
|
||||
$warning = '';
|
||||
|
||||
if (empty($this->config->getAppValue('bbb', 'api.url')) || empty($this->config->getAppValue('bbb', 'api.secret'))) {
|
||||
|
@ -43,8 +40,7 @@ class Personal implements ISettings
|
|||
/**
|
||||
* @return string the section ID, e.g. 'sharing'
|
||||
*/
|
||||
public function getSection()
|
||||
{
|
||||
public function getSection() {
|
||||
return 'bbb';
|
||||
}
|
||||
|
||||
|
@ -55,8 +51,7 @@ class Personal implements ISettings
|
|||
*
|
||||
* E.g.: 70
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
public function getPriority() {
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,15 +6,13 @@ use OCP\IL10N;
|
|||
use OCP\IURLGenerator;
|
||||
use OCP\Settings\IIconSection;
|
||||
|
||||
class Section implements IIconSection
|
||||
{
|
||||
class Section implements IIconSection {
|
||||
/** @var IL10N */
|
||||
private $l;
|
||||
/** @var IURLGenerator */
|
||||
private $url;
|
||||
|
||||
public function __construct(IL10N $l, IURLGenerator $url)
|
||||
{
|
||||
public function __construct(IL10N $l, IURLGenerator $url) {
|
||||
$this->l = $l;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
@ -25,8 +23,7 @@ class Section implements IIconSection
|
|||
*
|
||||
* @returns string
|
||||
*/
|
||||
public function getID()
|
||||
{
|
||||
public function getID() {
|
||||
return 'bbb';
|
||||
}
|
||||
|
||||
|
@ -36,8 +33,7 @@ class Section implements IIconSection
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
public function getName() {
|
||||
return "BigBlueButton";
|
||||
}
|
||||
|
||||
|
@ -48,16 +44,14 @@ class Section implements IIconSection
|
|||
*
|
||||
* E.g.: 70
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
public function getPriority() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
public function getIcon() {
|
||||
return $this->url->imagePath('bbb', 'app-dark.svg');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ script('bbb', 'manager');
|
|||
|
||||
<div id="bbb-root"></div>
|
||||
|
||||
<?php if(!empty($_['warning'])): ?>
|
||||
<?php if (!empty($_['warning'])): ?>
|
||||
<div id="bbb-warning">
|
||||
<span class="icon icon-error-color icon-visible"></span> <?php p($_['warning']); ?>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Tests\Integration\Db;
|
||||
|
||||
use OC;
|
||||
|
@ -25,8 +26,7 @@ class RoomMapperTest extends TestCase {
|
|||
/** @var string */
|
||||
private $uid;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->db = OC::$server->getDatabaseConnection();
|
||||
$this->mapper = new RoomMapper($this->db);
|
||||
|
@ -36,8 +36,7 @@ class RoomMapperTest extends TestCase {
|
|||
$this->uid = $this->getRandomString();
|
||||
}
|
||||
|
||||
public function testInsert()
|
||||
{
|
||||
public function testInsert() {
|
||||
$room = $this->insert($this->uid, $this->userId);
|
||||
|
||||
$this->assertEquals($this->uid, $room->getUid());
|
||||
|
@ -48,8 +47,7 @@ class RoomMapperTest extends TestCase {
|
|||
/**
|
||||
* @depends testInsert
|
||||
*/
|
||||
public function testFind()
|
||||
{
|
||||
public function testFind() {
|
||||
$newRoom = $this->insert($this->uid, $this->userId);
|
||||
|
||||
$room = $this->mapper->find($newRoom->getId());
|
||||
|
@ -62,8 +60,7 @@ class RoomMapperTest extends TestCase {
|
|||
/**
|
||||
* @depends testInsert
|
||||
*/
|
||||
public function testFindByUid()
|
||||
{
|
||||
public function testFindByUid() {
|
||||
$newRoom = $this->insert($this->uid, $this->userId);
|
||||
|
||||
$room = $this->mapper->findByUid($this->uid);
|
||||
|
@ -76,8 +73,7 @@ class RoomMapperTest extends TestCase {
|
|||
/**
|
||||
* @depends testInsert
|
||||
*/
|
||||
public function testFindAll()
|
||||
{
|
||||
public function testFindAll() {
|
||||
$room = $this->insert($this->uid, $this->userId);
|
||||
|
||||
$foreignRoom1 = $this->insert($this->getRandomString(), $this->getRandomString());
|
||||
|
@ -102,18 +98,16 @@ class RoomMapperTest extends TestCase {
|
|||
$this->mapper->delete($foreignRoom2);
|
||||
$this->mapper->delete($foreignRoom3);
|
||||
|
||||
foreach($shares as $share) {
|
||||
foreach ($shares as $share) {
|
||||
$this->shareMapper->delete($share);
|
||||
}
|
||||
}
|
||||
|
||||
private function getRandomString(): string
|
||||
{
|
||||
private function getRandomString(): string {
|
||||
return \OC::$server->getSecureRandom()->generate(18, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE);
|
||||
}
|
||||
|
||||
private function insert($uid, $userId): Room
|
||||
{
|
||||
private function insert($uid, $userId): Room {
|
||||
$room = new Room();
|
||||
$room->setUid($uid);
|
||||
$room->setName('random name');
|
||||
|
@ -127,8 +121,7 @@ class RoomMapperTest extends TestCase {
|
|||
return $this->mapper->insert($room);
|
||||
}
|
||||
|
||||
private function insertShare($id, $type, $with, $permission = RoomShare::PERMISSION_ADMIN): RoomShare
|
||||
{
|
||||
private function insertShare($id, $type, $with, $permission = RoomShare::PERMISSION_ADMIN): RoomShare {
|
||||
$roomShare = new RoomShare();
|
||||
|
||||
$roomShare->setRoomId($id);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
namespace OCA\BigBlueButton\Tests\Controller;
|
||||
|
||||
namespace OCA\BigBlueButton\Tests\Controller;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OCP\AppFramework\Http\RedirectResponse;
|
||||
|
@ -19,8 +19,7 @@ use OCA\BigBlueButton\Permission;
|
|||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
||||
class JoinControllerTest extends TestCase
|
||||
{
|
||||
class JoinControllerTest extends TestCase {
|
||||
private $request;
|
||||
private $service;
|
||||
private $userSession;
|
||||
|
@ -31,8 +30,7 @@ class JoinControllerTest extends TestCase
|
|||
private $permission;
|
||||
private $room;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->request = $this->createMock(IRequest::class);
|
||||
|
@ -64,8 +62,7 @@ class JoinControllerTest extends TestCase
|
|||
$this->room->password = 'password_foo';
|
||||
}
|
||||
|
||||
public function testNonExistingRoom()
|
||||
{
|
||||
public function testNonExistingRoom() {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$this->service
|
||||
->expects($this->once())
|
||||
|
@ -75,8 +72,7 @@ class JoinControllerTest extends TestCase
|
|||
$this->controller->index(null);
|
||||
}
|
||||
|
||||
public function testUserIsLoggedIn()
|
||||
{
|
||||
public function testUserIsLoggedIn() {
|
||||
$this->controller->setToken($this->room->uid);
|
||||
$this->service
|
||||
->expects($this->once())
|
||||
|
@ -115,8 +111,7 @@ class JoinControllerTest extends TestCase
|
|||
$this->assertEquals($url, $result->getRedirectURL());
|
||||
}
|
||||
|
||||
public function testUserNeedsToAuthenticateForInternal()
|
||||
{
|
||||
public function testUserNeedsToAuthenticateForInternal() {
|
||||
$this->room->setAccess(Room::ACCESS_INTERNAL);
|
||||
|
||||
$this->controller->setToken($this->room->uid);
|
||||
|
@ -144,8 +139,7 @@ class JoinControllerTest extends TestCase
|
|||
$this->assertEquals(Http::STATUS_SEE_OTHER, $result->getStatus());
|
||||
}
|
||||
|
||||
public function testUserNeedsToAuthenticateForInternalRestricted()
|
||||
{
|
||||
public function testUserNeedsToAuthenticateForInternalRestricted() {
|
||||
$this->room->setAccess(Room::ACCESS_INTERNAL_RESTRICTED);
|
||||
|
||||
$this->controller->setToken($this->room->uid);
|
||||
|
@ -173,8 +167,7 @@ class JoinControllerTest extends TestCase
|
|||
$this->assertEquals(Http::STATUS_SEE_OTHER, $result->getStatus());
|
||||
}
|
||||
|
||||
public function testDisplaynames()
|
||||
{
|
||||
public function testDisplaynames() {
|
||||
$this->controller->setToken($this->room->uid);
|
||||
$this->service
|
||||
->expects($this->once())
|
||||
|
@ -202,8 +195,7 @@ class JoinControllerTest extends TestCase
|
|||
$this->assertInstanceOf(RedirectResponse::class, $response);
|
||||
}
|
||||
|
||||
private function invalidDisplayname($displayname)
|
||||
{
|
||||
private function invalidDisplayname($displayname) {
|
||||
$response = $this->controller->index($displayname);
|
||||
|
||||
$this->assertInstanceOf(TemplateResponse::class, $response);
|
||||
|
@ -211,8 +203,7 @@ class JoinControllerTest extends TestCase
|
|||
$this->assertTrue($response->getParams()['wrongdisplayname']);
|
||||
}
|
||||
|
||||
public function testPasswordRequired()
|
||||
{
|
||||
public function testPasswordRequired() {
|
||||
$this->room->setAccess(Room::ACCESS_PASSWORD);
|
||||
$this->room->setPassword('asdf');
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
namespace OCA\BigBlueButton\Tests\Controller;
|
||||
|
||||
namespace OCA\BigBlueButton\Tests\Controller;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OCP\IRequest;
|
||||
|
@ -8,13 +8,11 @@ use OCA\BigBlueButton\Service\RoomService;
|
|||
use OCA\BigBlueButton\Controller\RoomShareController;
|
||||
use OCA\BigBlueButton\Db\Room;
|
||||
use OCA\BigBlueButton\Db\RoomShare;
|
||||
use OCA\BigBlueButton\Service\RoomShareNotFound;
|
||||
use OCA\BigBlueButton\Service\RoomShareService;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\IUserManager;
|
||||
|
||||
class RoomShareControllerTest extends TestCase
|
||||
{
|
||||
class RoomShareControllerTest extends TestCase {
|
||||
private $request;
|
||||
private $service;
|
||||
private $roomService;
|
||||
|
@ -23,8 +21,7 @@ class RoomShareControllerTest extends TestCase
|
|||
|
||||
private $userId = 'user_foo';
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->request = $this->createMock(IRequest::class);
|
||||
|
@ -42,15 +39,13 @@ class RoomShareControllerTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testIndexWithoutRoomId()
|
||||
{
|
||||
public function testIndexWithoutRoomId() {
|
||||
$response = $this->controller->index();
|
||||
|
||||
$this->assertEquals(Http::STATUS_BAD_REQUEST, $response->getStatus());
|
||||
}
|
||||
|
||||
public function testIndexWithoutPermission()
|
||||
{
|
||||
public function testIndexWithoutPermission() {
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('getParam')
|
||||
|
@ -71,8 +66,7 @@ class RoomShareControllerTest extends TestCase
|
|||
$this->assertEquals(Http::STATUS_FORBIDDEN, $response->getStatus());
|
||||
}
|
||||
|
||||
public function testIndexWithoutShares()
|
||||
{
|
||||
public function testIndexWithoutShares() {
|
||||
$roomId = 1234;
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
|
@ -100,8 +94,7 @@ class RoomShareControllerTest extends TestCase
|
|||
$this->assertEquals([], $response->getData());
|
||||
}
|
||||
|
||||
public function testIndexWithShares()
|
||||
{
|
||||
public function testIndexWithShares() {
|
||||
$roomId = 1234;
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Tests;
|
||||
|
||||
use OCA\BigBlueButton\Db\Room;
|
||||
|
@ -9,8 +10,7 @@ use OCP\IGroupManager;
|
|||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PermissionTest extends TestCase
|
||||
{
|
||||
class PermissionTest extends TestCase {
|
||||
/** @var Permission */
|
||||
private $permission;
|
||||
|
||||
|
@ -20,8 +20,7 @@ class PermissionTest extends TestCase
|
|||
/** @var RoomShareService|MockObject */
|
||||
private $roomShareService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
/** @var IGroupManager|MockObject */
|
||||
|
@ -36,8 +35,7 @@ class PermissionTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testIsUser()
|
||||
{
|
||||
public function testIsUser() {
|
||||
$room = $this->createRoom(1, 'foo');
|
||||
|
||||
$this->roomShareService
|
||||
|
@ -67,8 +65,7 @@ class PermissionTest extends TestCase
|
|||
$this->assertTrue($this->permission->isUser($room, 'group_user'));
|
||||
}
|
||||
|
||||
private function createRoom(int $id, string $userId): Room
|
||||
{
|
||||
private function createRoom(int $id, string $userId): Room {
|
||||
$room = new Room();
|
||||
|
||||
$room->setId($id);
|
||||
|
@ -77,8 +74,7 @@ class PermissionTest extends TestCase
|
|||
return $room;
|
||||
}
|
||||
|
||||
private function createRoomShare(int $type, string $with, int $permission): RoomShare
|
||||
{
|
||||
private function createRoomShare(int $type, string $with, int $permission): RoomShare {
|
||||
$share = new RoomShare();
|
||||
|
||||
$share->setShareType($type);
|
||||
|
|
Loading…
Reference in New Issue