|
|
|
@ -45,6 +45,7 @@ use OCP\IUserManager; |
|
|
|
use Psr\Log\LoggerInterface; |
|
|
|
|
|
|
|
/** |
|
|
|
* @psalm-import-type TalkSignalingFederationSettings from ResponseDefinitions |
|
|
|
* @psalm-import-type TalkSignalingSession from ResponseDefinitions |
|
|
|
* @psalm-import-type TalkSignalingSettings from ResponseDefinitions |
|
|
|
*/ |
|
|
|
@ -107,7 +108,7 @@ class SignalingController extends OCSController { |
|
|
|
* Get the signaling settings |
|
|
|
* |
|
|
|
* @param string $token Token of the room |
|
|
|
* @return DataResponse<Http::STATUS_OK, TalkSignalingSettings, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND, array<empty>, array{}> |
|
|
|
* @return DataResponse<Http::STATUS_OK, TalkSignalingSettings, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND, null, array{}> |
|
|
|
* |
|
|
|
* 200: Signaling settings returned |
|
|
|
* 401: Recording request invalid |
|
|
|
@ -123,7 +124,7 @@ class SignalingController extends OCSController { |
|
|
|
|
|
|
|
if (!empty($this->request->getHeader('Talk-Recording-Random')) || !empty($this->request->getHeader('Talk-Recording-Checksum'))) { |
|
|
|
if (!$this->validateRecordingBackendRequest('')) { |
|
|
|
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED); |
|
|
|
$response = new DataResponse(null, Http::STATUS_UNAUTHORIZED); |
|
|
|
$response->throttle(['action' => 'talkRecordingSecret']); |
|
|
|
return $response; |
|
|
|
} |
|
|
|
@ -158,7 +159,7 @@ class SignalingController extends OCSController { |
|
|
|
$room = null; |
|
|
|
} |
|
|
|
} catch (RoomNotFoundException|ParticipantNotFoundException) { |
|
|
|
$response = new DataResponse([], Http::STATUS_NOT_FOUND); |
|
|
|
$response = new DataResponse(null, Http::STATUS_NOT_FOUND); |
|
|
|
$response->throttle(['token' => $token, 'action' => $action]); |
|
|
|
return $response; |
|
|
|
} |
|
|
|
@ -222,15 +223,18 @@ class SignalingController extends OCSController { |
|
|
|
return new DataResponse($data); |
|
|
|
} |
|
|
|
|
|
|
|
private function getFederationSettings(?Room $room): array { |
|
|
|
/** |
|
|
|
* @psalm-return ?TalkSignalingFederationSettings |
|
|
|
*/ |
|
|
|
private function getFederationSettings(?Room $room): ?array { |
|
|
|
if ($room === null || !$room->isFederatedConversation()) { |
|
|
|
return []; |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
$participant = $this->participantService->getParticipant($room, $this->userId); |
|
|
|
} catch (ParticipantNotFoundException $e) { |
|
|
|
return []; |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** @var \OCA\Talk\Federation\Proxy\TalkV1\Controller\SignalingController $proxy */ |
|
|
|
@ -238,7 +242,7 @@ class SignalingController extends OCSController { |
|
|
|
$response = $proxy->getSettings($room, $participant); |
|
|
|
|
|
|
|
if ($response->getStatus() === Http::STATUS_NOT_FOUND) { |
|
|
|
return []; |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** @var TalkSignalingSettings $data */ |
|
|
|
@ -262,7 +266,7 @@ class SignalingController extends OCSController { |
|
|
|
* |
|
|
|
* @param int $serverId ID of the signaling server |
|
|
|
* @psalm-param non-negative-int $serverId |
|
|
|
* @return DataResponse<Http::STATUS_OK, array<string, mixed>, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{error: string, version?: string}, array{}> |
|
|
|
* @return DataResponse<Http::STATUS_OK, array<string, mixed>, array{}>|DataResponse<Http::STATUS_NOT_FOUND, null, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{error: string, version?: string}, array{}> |
|
|
|
* |
|
|
|
* 200: Welcome message returned |
|
|
|
* 404: Signaling server not found |
|
|
|
@ -271,7 +275,7 @@ class SignalingController extends OCSController { |
|
|
|
public function getWelcomeMessage(int $serverId): DataResponse { |
|
|
|
$signalingServers = $this->talkConfig->getSignalingServers(); |
|
|
|
if (empty($signalingServers) || !isset($signalingServers[$serverId])) { |
|
|
|
return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
|
|
return new DataResponse(null, Http::STATUS_NOT_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
$url = rtrim($signalingServers[$serverId]['server'], '/'); |
|
|
|
@ -349,7 +353,7 @@ class SignalingController extends OCSController { |
|
|
|
* |
|
|
|
* @param string $token Token of the room |
|
|
|
* @param string $messages JSON encoded messages |
|
|
|
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, string, array{}> |
|
|
|
* @return DataResponse<Http::STATUS_OK, null, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, string, array{}> |
|
|
|
* |
|
|
|
* 200: Signaling message sent successfully |
|
|
|
* 400: Sending signaling message is not possible |
|
|
|
@ -409,7 +413,7 @@ class SignalingController extends OCSController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return new DataResponse($response); |
|
|
|
return new DataResponse(null); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -494,7 +498,7 @@ class SignalingController extends OCSController { |
|
|
|
* Get signaling messages |
|
|
|
* |
|
|
|
* @param string $token Token of the room |
|
|
|
* @return DataResponse<Http::STATUS_OK|Http::STATUS_NOT_FOUND|Http::STATUS_CONFLICT, list<array{type: string, data: TalkSignalingSession[]|string}>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, string, array{}> |
|
|
|
* @return DataResponse<Http::STATUS_OK|Http::STATUS_NOT_FOUND|Http::STATUS_CONFLICT, list<array{type: string, data: list<TalkSignalingSession>|string}>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, string, array{}> |
|
|
|
* |
|
|
|
* 200: Signaling messages returned |
|
|
|
* 400: Getting signaling messages is not possible |
|
|
|
@ -597,7 +601,7 @@ class SignalingController extends OCSController { |
|
|
|
/** |
|
|
|
* @param Room $room |
|
|
|
* @param int $pingTimestamp |
|
|
|
* @return TalkSignalingSession[] |
|
|
|
* @return list<TalkSignalingSession> |
|
|
|
*/ |
|
|
|
protected function getUsersInRoom(Room $room, int $pingTimestamp): array { |
|
|
|
$usersInRoom = []; |
|
|
|
@ -699,7 +703,7 @@ class SignalingController extends OCSController { |
|
|
|
* See sections "Backend validation" in |
|
|
|
* https://nextcloud-spreed-signaling.readthedocs.io/en/latest/standalone-signaling-api-v1/#backend-requests
|
|
|
|
* |
|
|
|
* @return DataResponse<Http::STATUS_OK, array{type: string, error?: array{code: string, message: string}, auth?: array{version: string, userid?: string, user?: array<string, mixed>}, room?: array{version: string, roomid?: string, properties?: array<string, mixed>, permissions?: string[], session?: array<string, mixed>}}, array{}> |
|
|
|
* @return DataResponse<Http::STATUS_OK, array{type: string, error?: array{code: string, message: string}, auth?: array{version: string, userid?: string, user?: array<string, mixed>}, room?: array{version: string, roomid?: string, properties?: array<string, mixed>, permissions?: list<string>, session?: array<string, mixed>}}, array{}> |
|
|
|
* |
|
|
|
* 200: Always, sorry about that |
|
|
|
*/ |
|
|
|
@ -797,7 +801,7 @@ class SignalingController extends OCSController { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return DataResponse<Http::STATUS_OK, array{type: string, error?: array{code: string, message: string}, room?: array{version: string, roomid: string, properties: array<string, mixed>, permissions: string[], session?: array<string, mixed>}}, array{}> |
|
|
|
* @return DataResponse<Http::STATUS_OK, array{type: string, error?: array{code: string, message: string}, room?: array{version: string, roomid: string, properties: array<string, mixed>, permissions: list<string>, session?: array<string, mixed>}}, array{}> |
|
|
|
*/ |
|
|
|
private function backendRoom(array $roomRequest): DataResponse { |
|
|
|
$token = $roomRequest['roomid']; // It's actually the room token
|
|
|
|
|