Browse Source

Handle dial-out exceptions

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/10733/head
Joas Schilling 2 years ago
parent
commit
5e06dce59c
No known key found for this signature in database GPG Key ID: 74434EFE0D2E2205
  1. 2
      lib/Controller/CallController.php
  2. 2
      lib/Exceptions/DialOutFailedException.php
  3. 5
      lib/Signaling/BackendNotifier.php
  4. 48
      openapi.json
  5. 1
      psalm.xml
  6. 7
      tests/stubs/GuzzleHttp_Exception_ServerException.php
  7. 23
      tests/stubs/oc_http_client_response.php

2
lib/Controller/CallController.php

@ -208,7 +208,7 @@ class CallController extends AEnvironmentAwareController {
* Call a SIP dial-out attendee
*
* @param int $attendeeId ID of the attendee to call
* @return DataResponse<Http::STATUS_CREATED|Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, array<empty>, array{}>
* @return DataResponse<Http::STATUS_CREATED|Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND|Http::STATUS_NOT_IMPLEMENTED, array{error?: string, message?: string}, array{}>
*
* 201: Dial-out initiated successfully
* 400: SIP dial-out not possible

2
lib/Exceptions/DialOutFailedException.php

@ -26,8 +26,6 @@ declare(strict_types=1);
namespace OCA\Talk\Exceptions;
use parallel\Events;
class DialOutFailedException extends \RuntimeException {
public function __construct(
string $errorCode,

5
lib/Signaling/BackendNotifier.php

@ -93,7 +93,10 @@ class BackendNotifier {
}
$this->logger->error('Failed to send message to signaling server, giving up!', ['exception' => $e]);
return new Response($e->getResponse());
if ($e->hasResponse()) {
return new Response($e->getResponse());
}
throw $e;
} catch (\Exception $e) {
$this->logger->error('Failed to send message to signaling server', ['exception' => $e]);
throw $e;

48
openapi.json

@ -4616,7 +4616,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
@ -4644,7 +4654,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
@ -4672,7 +4692,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
@ -4700,7 +4730,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}

1
psalm.xml

@ -89,6 +89,7 @@
<file name="tests/stubs/oc_comments_manager.php" />
<file name="tests/stubs/oc_core_command_base.php" />
<file name="tests/stubs/oc_hooks_emitter.php" />
<file name="tests/stubs/oc_http_client_response.php" />
<file name="tests/stubs/oca_circles.php" />
<file name="tests/stubs/oca_files_events.php" />
<file name="tests/stubs/GuzzleHttp_Exception_ClientException.php" />

7
tests/stubs/GuzzleHttp_Exception_ServerException.php

@ -2,5 +2,12 @@
namespace GuzzleHttp\Exception;
use Psr\Http\Message\ResponseInterface;
class ServerException extends \RuntimeException {
public function getResponse(): ResponseInterface {
}
public function hasResponse(): bool {
}
}

23
tests/stubs/oc_http_client_response.php

@ -0,0 +1,23 @@
<?php
namespace OC\Http\Client;
use OCP\Http\Client\IResponse;
use Psr\Http\Message\ResponseInterface;
class Response implements IResponse {
public function __construct(ResponseInterface $response, $stream = false) {
}
public function getBody() {
}
public function getStatusCode(): int {
}
public function getHeader(string $key): string {
}
public function getHeaders(): array {
}
}
Loading…
Cancel
Save