Combine the createRoom methods

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-07-11 16:06:01 +02:00
Родитель 9601b47342
Коммит 7c8441c793
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E166FD8976B3BAC8
4 изменённых файлов: 46 добавлений и 27 удалений

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

@ -95,21 +95,9 @@ return [
],
],
[
'name' => 'Room#createOneToOneRoom',
'url' => '/api/{apiVersion}/oneToOne',
'verb' => 'PUT',
'requirements' => ['apiVersion' => 'v1'],
],
[
'name' => 'Room#createGroupRoom',
'url' => '/api/{apiVersion}/group',
'verb' => 'PUT',
'requirements' => ['apiVersion' => 'v1'],
],
[
'name' => 'Room#createPublicRoom',
'url' => '/api/{apiVersion}/public',
'verb' => 'PUT',
'name' => 'Room#createRoom',
'url' => '/api/{apiVersion}/room',
'verb' => 'POST',
'requirements' => ['apiVersion' => 'v1'],
],
[

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

@ -33,9 +33,12 @@
createOneToOneVideoCall: function(recipientUserId) {
console.log(recipientUserId);
$.ajax({
url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'oneToOne',
type: 'PUT',
data: 'targetUserName='+recipientUserId,
url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'room',
type: 'POST',
data: {
invite: recipientUserId,
roomType: 1
},
beforeSend: function (request) {
request.setRequestHeader('Accept', 'application/json');
},
@ -45,9 +48,12 @@
createGroupVideoCall: function(groupId) {
console.log(groupId);
$.ajax({
url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'group',
type: 'PUT',
data: 'targetGroupName='+groupId,
url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'room',
type: 'POST',
data: {
invite: groupId,
roomType: 2
},
beforeSend: function (request) {
request.setRequestHeader('Accept', 'application/json');
},
@ -57,8 +63,11 @@
createPublicVideoCall: function() {
console.log("Creating a new public room.");
$.ajax({
url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'public',
type: 'PUT',
url: OC.linkToOCS('apps/spreed/api/v1', 2) + 'room',
type: 'POST',
data: {
roomType: 3
},
beforeSend: function (request) {
request.setRequestHeader('Accept', 'application/json');
},

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

@ -123,7 +123,7 @@ class PageController extends Controller {
$token = '';
}
} else {
$response = $this->api->createOneToOneRoom($callUser);
$response = $this->api->createRoom(Room::ONE_TO_ONE_CALL, $callUser);
if ($response->getStatus() !== Http::STATUS_NOT_FOUND) {
$data = $response->getData();
return new RedirectResponse($this->url->linkToRoute('spreed.Page.showCall', ['token' => $data['token']]));

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

@ -241,6 +241,28 @@ class RoomController extends OCSController {
return $roomData;
}
/**
* Initiates a one-to-one video call from the current user to the recipient
*
* @NoAdminRequired
*
* @param int $roomType
* @param string $invite
* @return DataResponse
*/
public function createRoom($roomType, $invite = '') {
switch ((int) $roomType) {
case Room::ONE_TO_ONE_CALL:
return $this->createOneToOneRoom($invite);
case Room::GROUP_CALL:
return $this->createGroupRoom($invite);
case Room::PUBLIC_CALL:
return $this->createPublicRoom();
}
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
/**
* Initiates a one-to-one video call from the current user to the recipient
*
@ -249,7 +271,7 @@ class RoomController extends OCSController {
* @param string $targetUserName
* @return DataResponse
*/
public function createOneToOneRoom($targetUserName) {
protected function createOneToOneRoom($targetUserName) {
// Get the user
$targetUser = $this->userManager->get($targetUserName);
$currentUser = $this->userManager->get($this->userId);
@ -280,7 +302,7 @@ class RoomController extends OCSController {
* @param string $targetGroupName
* @return DataResponse
*/
public function createGroupRoom($targetGroupName) {
protected function createGroupRoom($targetGroupName) {
$targetGroup = $this->groupManager->get($targetGroupName);
$currentUser = $this->userManager->get($this->userId);
@ -312,7 +334,7 @@ class RoomController extends OCSController {
*
* @return DataResponse
*/
public function createPublicRoom() {
protected function createPublicRoom() {
$currentUser = $this->userManager->get($this->userId);
// Create the room