зеркало из https://github.com/nextcloud/spreed.git
Allow to make rooms public
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
c139e66af2
Коммит
bb41d6bfba
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче