, array{}> * @throws CannotReachRemoteException * * 200: List of peers in the call returned */ public function getPeersForCall(Room $room, Participant $participant): DataResponse { $proxy = $this->proxy->get( $participant->getAttendee()->getInvitedCloudId(), $participant->getAttendee()->getAccessToken(), $room->getRemoteServer() . '/ocs/v2.php/apps/spreed/api/v4/call/' . $room->getRemoteToken(), ); /** @var list $data */ $data = $this->proxy->getOCSData($proxy); /** @var list $data */ $data = $this->userConverter->convertAttendees($room, $data, 'actorType', 'actorId', 'displayName'); $statusCode = $proxy->getStatusCode(); if (!in_array($statusCode, [Http::STATUS_OK], true)) { $this->proxy->logUnexpectedStatusCode(__METHOD__, $proxy->getStatusCode()); throw new CannotReachRemoteException(); } return new DataResponse($data, $statusCode); } /** * @see \OCA\Talk\Controller\CallController::joinFederatedCall() * * @param Room $room the federated room to join the call in * @param Participant $participant the federated user that will join the * call; the participant must have a session * @param int<0, 15> $flags In-Call flags * @psalm-param int-mask-of $flags * @param bool $silent Join the call silently * @param bool $recordingConsent Agreement to be recorded * @return DataResponse|DataResponse * @throws CannotReachRemoteException * * 200: Federated user is now in the call * 400: Conditions to join not met * 404: Room not found */ public function joinFederatedCall(Room $room, Participant $participant, int $flags, bool $silent, bool $recordingConsent): DataResponse { $options = [ 'sessionId' => $participant->getSession()->getSessionId(), 'flags' => $flags, 'silent' => $silent, 'recordingConsent' => $recordingConsent, ]; $proxy = $this->proxy->post( $participant->getAttendee()->getInvitedCloudId(), $participant->getAttendee()->getAccessToken(), $room->getRemoteServer() . '/ocs/v2.php/apps/spreed/api/v4/call/' . $room->getRemoteToken() . '/federation', $options, ); $statusCode = $proxy->getStatusCode(); if (!in_array($statusCode, [Http::STATUS_OK, Http::STATUS_BAD_REQUEST, Http::STATUS_NOT_FOUND], true)) { $this->proxy->logUnexpectedStatusCode(__METHOD__, $proxy->getStatusCode()); throw new CannotReachRemoteException(); } if ($statusCode === Http::STATUS_BAD_REQUEST) { /** @var array{error: string} $data */ $data = $this->proxy->getOCSData($proxy, [Http::STATUS_BAD_REQUEST]); return new DataResponse($data, $statusCode); } return new DataResponse(null, $statusCode); } /** * @see \OCA\Talk\Controller\CallController::ringAttendee() * * @param int $attendeeId ID of the attendee to ring * @return DataResponse|DataResponse * @throws CannotReachRemoteException * * 200: Attendee rang successfully * 400: Ringing attendee is not possible * 404: Attendee could not be found */ public function ringAttendee(Room $room, Participant $participant, int $attendeeId): DataResponse { $proxy = $this->proxy->post( $participant->getAttendee()->getInvitedCloudId(), $participant->getAttendee()->getAccessToken(), $room->getRemoteServer() . '/ocs/v2.php/apps/spreed/api/v4/call/' . $room->getRemoteToken() . '/ring/' . $attendeeId, ); $statusCode = $proxy->getStatusCode(); if (!in_array($statusCode, [Http::STATUS_OK, Http::STATUS_BAD_REQUEST, Http::STATUS_NOT_FOUND], true)) { $this->proxy->logUnexpectedStatusCode(__METHOD__, $proxy->getStatusCode()); throw new CannotReachRemoteException(); } if ($statusCode === Http::STATUS_BAD_REQUEST) { /** @var array{error: string} $data */ $data = $this->proxy->getOCSData($proxy, [Http::STATUS_BAD_REQUEST]); return new DataResponse($data, $statusCode); } return new DataResponse(null, $statusCode); } /** * @see \OCA\Talk\Controller\CallController::updateFederatedCallFlags() * * @param Room $room the federated room to update the call flags in * @param Participant $participant the federated user to update the call * flags; the participant must have a session * @param int<0, 15> $flags New flags * @psalm-param int-mask-of $flags New flags * @return DataResponse * @throws CannotReachRemoteException * * 200: In-call flags updated successfully for federated user * 400: Updating in-call flags is not possible * 404: Room not found */ public function updateFederatedCallFlags(Room $room, Participant $participant, int $flags): DataResponse { $options = [ 'sessionId' => $participant->getSession()->getSessionId(), 'flags' => $flags, ]; $proxy = $this->proxy->put( $participant->getAttendee()->getInvitedCloudId(), $participant->getAttendee()->getAccessToken(), $room->getRemoteServer() . '/ocs/v2.php/apps/spreed/api/v4/call/' . $room->getRemoteToken() . '/federation', $options, ); $statusCode = $proxy->getStatusCode(); if (!in_array($statusCode, [Http::STATUS_OK, Http::STATUS_BAD_REQUEST, Http::STATUS_NOT_FOUND], true)) { $this->proxy->logUnexpectedStatusCode(__METHOD__, $proxy->getStatusCode()); throw new CannotReachRemoteException(); } return new DataResponse(null, $statusCode); } /** * @see \OCA\Talk\Controller\CallController::leaveFederatedCall() * * @param Room $room the federated room to leave the call in * @param Participant $participant the federated user that will leave the * call; the participant must have a session * @return DataResponse * @throws CannotReachRemoteException * * 200: Federated user left the call * 404: Room not found */ public function leaveFederatedCall(Room $room, Participant $participant): DataResponse { $options = [ 'sessionId' => $participant->getSession()->getSessionId(), ]; $proxy = $this->proxy->delete( $participant->getAttendee()->getInvitedCloudId(), $participant->getAttendee()->getAccessToken(), $room->getRemoteServer() . '/ocs/v2.php/apps/spreed/api/v4/call/' . $room->getRemoteToken() . '/federation', $options, ); $statusCode = $proxy->getStatusCode(); if (!in_array($statusCode, [Http::STATUS_OK, Http::STATUS_NOT_FOUND], true)) { $this->proxy->logUnexpectedStatusCode(__METHOD__, $proxy->getStatusCode()); throw new CannotReachRemoteException(); } return new DataResponse(null, $statusCode); } }