Skip to content

Commit

Permalink
Return "DataResponse" to be OCS compatible.
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Bauch <bauch@struktur.de>
  • Loading branch information
fancycode authored and nickvergessen committed Feb 2, 2018
1 parent f54e9de commit e3ef4d2
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/Controller/SignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use OCA\Spreed\Signaling\Messages;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\OCSController;
use OCP\IDBConnection;
use OCP\IRequest;
Expand Down Expand Up @@ -279,12 +278,12 @@ protected function getInputStream() {
* @NoCSRFRequired
* @PublicPage
*
* @return JSONResponse
* @return DataResponse
*/
public function backend() {
$json = $this->getInputStream();
if (!$this->validateBackendRequest($json)) {
return new JSONResponse([
return new DataResponse([
'type' => 'error',
'error' => [
'code' => 'invalid_request',
Expand All @@ -305,7 +304,7 @@ public function backend() {
// Ping sessions connected to a room.
return $this->backendPing($message['ping']);
default:
return new JSONResponse([
return new DataResponse([
'type' => 'error',
'error' => [
'code' => 'unknown_type',
Expand All @@ -319,7 +318,7 @@ private function backendAuth($auth) {
$params = $auth['params'];
$userId = $params['userid'];
if (!$this->config->validateSignalingTicket($userId, $params['ticket'])) {
return new JSONResponse([
return new DataResponse([
'type' => 'error',
'error' => [
'code' => 'invalid_ticket',
Expand All @@ -331,7 +330,7 @@ private function backendAuth($auth) {
if (!empty($userId)) {
$user = $this->userManager->get($userId);
if (!$user instanceof IUser) {
return new JSONResponse([
return new DataResponse([
'type' => 'error',
'error' => [
'code' => 'no_such_user',
Expand All @@ -353,7 +352,7 @@ private function backendAuth($auth) {
'displayname' => $user->getDisplayName(),
];
}
return new JSONResponse($response);
return new DataResponse($response);
}

private function backendRoom($roomRequest) {
Expand All @@ -364,7 +363,7 @@ private function backendRoom($roomRequest) {
try {
$room = $this->manager->getRoomByToken($roomId);
} catch (RoomNotFoundException $e) {
return new JSONResponse([
return new DataResponse([
'type' => 'error',
'error' => [
'code' => 'no_such_room',
Expand All @@ -389,7 +388,7 @@ private function backendRoom($roomRequest) {
$participant = $room->getParticipantBySession($sessionId);
} catch (ParticipantNotFoundException $e) {
// Return generic error to avoid leaking which rooms exist.
return new JSONResponse([
return new DataResponse([
'type' => 'error',
'error' => [
'code' => 'no_such_room',
Expand All @@ -414,14 +413,14 @@ private function backendRoom($roomRequest) {
],
],
];
return new JSONResponse($response);
return new DataResponse($response);
}

private function backendPing($request) {
try {
$room = $this->manager->getRoomByToken($request['roomid']);
} catch (RoomNotFoundException $e) {
return new JSONResponse([
return new DataResponse([
'type' => 'error',
'error' => [
'code' => 'no_such_room',
Expand All @@ -446,7 +445,7 @@ private function backendPing($request) {
'roomid' => $room->getToken(),
],
];
return new JSONResponse($response);
return new DataResponse($response);
}

}

0 comments on commit e3ef4d2

Please sign in to comment.