Skip to content

Commit

Permalink
fix(openapi): Fix empty array for SIP integration
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Nov 28, 2024
1 parent 11ebd83 commit fb50852
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ public function joinFederatedRoom(string $token, ?string $sessionId): DataRespon
* Verify a dial-in PIN (SIP bridge)
*
* @param numeric-string $pin PIN the participant used to dial-in
* @return DataResponse<Http::STATUS_OK, TalkRoom, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, array<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, TalkRoom, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, null, array{}>
*
* 200: Participant returned
* 401: SIP request invalid
Expand All @@ -1817,24 +1817,24 @@ public function joinFederatedRoom(string $token, ?string $sessionId): DataRespon
public function verifyDialInPin(string $pin): DataResponse {
try {
if (!$this->validateSIPBridgeRequest($this->room->getToken())) {
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED);
$response = new DataResponse(null, Http::STATUS_UNAUTHORIZED);
$response->throttle(['action' => 'talkSipBridgeSecret']);
return $response;
}
} catch (UnauthorizedException) {
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED);
$response = new DataResponse(null, Http::STATUS_UNAUTHORIZED);
$response->throttle(['action' => 'talkSipBridgeSecret']);
return $response;
}

if (!$this->talkConfig->isSIPConfigured()) {
return new DataResponse([], Http::STATUS_NOT_IMPLEMENTED);
return new DataResponse(null, Http::STATUS_NOT_IMPLEMENTED);
}

try {
$participant = $this->participantService->getParticipantByPin($this->room, $pin);
} catch (ParticipantNotFoundException $e) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse(null, Http::STATUS_NOT_FOUND);
}

return new DataResponse($this->formatRoom($this->room, $participant));
Expand All @@ -1845,7 +1845,7 @@ public function verifyDialInPin(string $pin): DataResponse {
*
* @param string $number E164 formatted phone number
* @param array{actorId?: string, actorType?: string, attendeeId?: int} $options Additional details to verify the validity of the request
* @return DataResponse<Http::STATUS_OK, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, array<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, null, array{}>
*
* 200: Participant created successfully
* 400: Phone number and details could not be confirmed
Expand All @@ -1860,32 +1860,32 @@ public function verifyDialInPin(string $pin): DataResponse {
public function verifyDialOutNumber(string $number, array $options = []): DataResponse {
try {
if (!$this->validateSIPBridgeRequest($this->room->getToken())) {
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED);
$response = new DataResponse(null, Http::STATUS_UNAUTHORIZED);
$response->throttle(['action' => 'talkSipBridgeSecret']);
return $response;
}
} catch (UnauthorizedException) {
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED);
$response = new DataResponse(null, Http::STATUS_UNAUTHORIZED);
$response->throttle(['action' => 'talkSipBridgeSecret']);
return $response;
}

if (!$this->talkConfig->isSIPConfigured() || !$this->talkConfig->isSIPDialOutEnabled()) {
return new DataResponse([], Http::STATUS_NOT_IMPLEMENTED);
return new DataResponse(null, Http::STATUS_NOT_IMPLEMENTED);
}

if (!isset($options['actorId'], $options['actorType']) || $options['actorType'] !== Attendee::ACTOR_PHONES) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
return new DataResponse(null, Http::STATUS_BAD_REQUEST);
}

try {
$participant = $this->participantService->getParticipantByActor($this->room, Attendee::ACTOR_PHONES, $options['actorId']);
} catch (ParticipantNotFoundException) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse(null, Http::STATUS_NOT_FOUND);
}

if ($participant->getAttendee()->getPhoneNumber() !== $number) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
return new DataResponse(null, Http::STATUS_BAD_REQUEST);
}

return new DataResponse($this->formatRoom($this->room, $participant));
Expand All @@ -1894,7 +1894,7 @@ public function verifyDialOutNumber(string $number, array $options = []): DataRe
/**
* Create a guest by their dial-in
*
* @return DataResponse<Http::STATUS_OK, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED, array<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, TalkRoom, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED, null, array{}>
*
* 200: Participant created successfully
* 400: SIP not enabled
Expand All @@ -1907,18 +1907,18 @@ public function verifyDialOutNumber(string $number, array $options = []): DataRe
public function createGuestByDialIn(): DataResponse {
try {
if (!$this->validateSIPBridgeRequest($this->room->getToken())) {
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED);
$response = new DataResponse(null, Http::STATUS_UNAUTHORIZED);
$response->throttle(['action' => 'talkSipBridgeSecret']);
return $response;
}
} catch (UnauthorizedException $e) {
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED);
$response = new DataResponse(null, Http::STATUS_UNAUTHORIZED);
$response->throttle(['action' => 'talkSipBridgeSecret']);
return $response;
}

if ($this->room->getSIPEnabled() !== Webinary::SIP_ENABLED_NO_PIN) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
return new DataResponse(null, Http::STATUS_BAD_REQUEST);
}

$participant = $this->participantService->joinRoomAsNewGuest($this->roomService, $this->room, '', true);
Expand All @@ -1931,7 +1931,7 @@ public function createGuestByDialIn(): DataResponse {
*
* @param string $callId The call ID provided by the SIP bridge earlier to uniquely identify the call to terminate
* @param array{actorId?: string, actorType?: string, attendeeId?: int} $options Additional details to verify the validity of the request
* @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, array<empty>, array{}>
* @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, null, array{}>
*
* 200: Call ID reset
* 400: Call ID mismatch or attendeeId not found in $options
Expand All @@ -1946,33 +1946,33 @@ public function createGuestByDialIn(): DataResponse {
public function rejectedDialOutRequest(string $callId, array $options = []): DataResponse {
try {
if (!$this->validateSIPBridgeRequest($this->room->getToken())) {
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED);
$response = new DataResponse(null, Http::STATUS_UNAUTHORIZED);
$response->throttle(['action' => 'talkSipBridgeSecret']);
return $response;
}
} catch (UnauthorizedException $e) {
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED);
$response = new DataResponse(null, Http::STATUS_UNAUTHORIZED);
$response->throttle(['action' => 'talkSipBridgeSecret']);
return $response;
}

if (empty($options['attendeeId'])) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
return new DataResponse(null, Http::STATUS_BAD_REQUEST);
}

if (!$this->talkConfig->isSIPConfigured() || !$this->talkConfig->isSIPDialOutEnabled()) {
return new DataResponse([], Http::STATUS_NOT_IMPLEMENTED);
return new DataResponse(null, Http::STATUS_NOT_IMPLEMENTED);
}

try {
$this->participantService->resetDialOutRequest($this->room, $options['attendeeId'], $callId);
} catch (ParticipantNotFoundException) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse(null, Http::STATUS_NOT_FOUND);
} catch (\InvalidArgumentException) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
return new DataResponse(null, Http::STATUS_BAD_REQUEST);
}

return new DataResponse([], Http::STATUS_OK);
return new DataResponse(null);
}

/**
Expand Down

0 comments on commit fb50852

Please sign in to comment.