2020-04-26 11:36:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OCA\BigBlueButton\Controller;
|
|
|
|
|
|
|
|
use OCP\IRequest;
|
|
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
|
|
use OCP\AppFramework\Controller;
|
|
|
|
|
|
|
|
use OCA\BigBlueButton\Service\RoomService;
|
|
|
|
|
|
|
|
class RoomController extends Controller
|
|
|
|
{
|
|
|
|
/** @var RoomService */
|
|
|
|
private $service;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
private $userId;
|
|
|
|
|
|
|
|
use Errors;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
$appName,
|
|
|
|
IRequest $request,
|
|
|
|
RoomService $service,
|
|
|
|
$userId
|
2020-04-29 11:08:49 +02:00
|
|
|
) {
|
2020-04-26 11:36:41 +02:00
|
|
|
parent::__construct($appName, $request);
|
|
|
|
$this->service = $service;
|
|
|
|
$this->userId = $userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
*/
|
|
|
|
public function index(): DataResponse
|
|
|
|
{
|
|
|
|
return new DataResponse($this->service->findAll($this->userId));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
*/
|
|
|
|
public function show(int $id): DataResponse
|
|
|
|
{
|
|
|
|
return $this->handleNotFound(function () use ($id) {
|
|
|
|
return $this->service->find($id, $this->userId);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
*/
|
|
|
|
public function create(
|
|
|
|
string $name,
|
|
|
|
string $welcome,
|
|
|
|
int $maxParticipants,
|
|
|
|
bool $record
|
2020-04-29 11:08:49 +02:00
|
|
|
): DataResponse {
|
2020-04-26 11:36:41 +02:00
|
|
|
return new DataResponse($this->service->create(
|
|
|
|
$name,
|
|
|
|
$welcome,
|
|
|
|
$maxParticipants,
|
|
|
|
$record,
|
|
|
|
$this->userId
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
*/
|
|
|
|
public function update(
|
|
|
|
int $id,
|
|
|
|
string $name,
|
|
|
|
string $welcome,
|
|
|
|
int $maxParticipants,
|
2020-06-04 18:56:55 +02:00
|
|
|
bool $record,
|
2020-06-17 08:19:54 +02:00
|
|
|
string $access,
|
|
|
|
bool $everyoneIsModerator
|
2020-04-29 11:08:49 +02:00
|
|
|
): DataResponse {
|
2020-06-17 08:19:54 +02:00
|
|
|
return $this->handleNotFound(function () use ($id, $name, $welcome, $maxParticipants, $record, $everyoneIsModerator, $access) {
|
|
|
|
return $this->service->update($id, $name, $welcome, $maxParticipants, $record, $access, $everyoneIsModerator, $this->userId);
|
2020-04-26 11:36:41 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
*/
|
|
|
|
public function destroy(int $id): DataResponse
|
|
|
|
{
|
|
|
|
return $this->handleNotFound(function () use ($id) {
|
|
|
|
return $this->service->delete($id, $this->userId);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|