Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2016-11-17 16:15:55 +01:00
Родитель c139e66af2
Коммит bb41d6bfba
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E166FD8976B3BAC8
3 изменённых файлов: 53 добавлений и 7 удалений

Просмотреть файл

@ -38,16 +38,21 @@ return [
'url' => '/messages',
'verb' => 'GET',
],
[
'name' => 'api#createRoom',
'url' => '/api/room',
'verb' => 'POST',
],
[
'name' => 'api#getRooms',
'url' => '/api/room',
'verb' => 'GET',
],
[
'name' => 'api#makePublic',
'url' => '/api/room/public',
'verb' => 'POST',
],
[
'name' => 'api#makePrivate',
'url' => '/api/room/public',
'verb' => 'DELETE',
],
[
'name' => 'api#addParticipantToRoom',
'url' => '/api/room/{roomId}',

Просмотреть файл

@ -336,6 +336,46 @@ class ApiController extends Controller {
return new JSONResponse([]);
}
/**
* @NoAdminRequired
*
* @param int $roomId
* @return JSONResponse
*/
public function makePublic($roomId) {
try {
$room = $this->manager->getRoomForParticipant($roomId, $this->userId);
} catch (RoomNotFoundException $e) {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
if ($room->getType() !== Room::PUBLIC_CALL) {
$room->changeType(Room::PUBLIC_CALL);
}
return new JSONResponse();
}
/**
* @NoAdminRequired
*
* @param int $roomId
* @return JSONResponse
*/
public function makePrivate($roomId) {
try {
$room = $this->manager->getRoomForParticipant($roomId, $this->userId);
} catch (RoomNotFoundException $e) {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
if ($room->getType() === Room::PUBLIC_CALL) {
$room->changeType(Room::GROUP_CALL);
}
return new JSONResponse();
}
/**
* @NoAdminRequired
*

Просмотреть файл

@ -32,6 +32,7 @@ use OCP\IUser;
class Room {
const ONE_TO_ONE_CALL = 1;
const GROUP_CALL = 2;
const PUBLIC_CALL = 3;
/** @var IDBConnection */
private $db;
@ -94,7 +95,7 @@ class Room {
}
/**
* @param int $newType Currently it is only allowed to change to: Room::GROUP_CALL
* @param int $newType Currently it is only allowed to change to: Room::GROUP_CALL, Room::PUBLIC_CALL
* @return bool True when the change was valid, false otherwise
*/
public function changeType($newType) {
@ -102,7 +103,7 @@ class Room {
return true;
}
if (!in_array($newType, [Room::GROUP_CALL])) {
if (!in_array($newType, [Room::GROUP_CALL, Room::PUBLIC_CALL])) {
return false;
}