Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SIP Dial-out): frontend support #10733

Merged
merged 17 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions css/icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
background-image: url(../img/icon-contacts-white.svg);
}

.app-talk .icon-phone,
.talk-modal .icon-phone,
.sidebar-callview .icon-phone,
#talk-panel .icon-phone,
#talk-sidebar .icon-phone,
#call-container .icon-phone,
.talkChatTab .icon-phone {
background-image: url(../img/icon-phone-white.svg);
}

.app-talk .icon-password,
.talk-modal .icon-password,
.sidebar-callview .icon-password,
Expand Down
1 change: 1 addition & 0 deletions img/icon-phone-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ protected function getActor(Room $room, string $actorType, string $actorId): arr
if ($actorType === Attendee::ACTOR_GUESTS || $actorType === Attendee::ACTOR_EMAILS) {
return $this->getGuest($room, $actorType, $actorId);
}
if ($actorType === Attendee::ACTOR_PHONES) {
return $this->getPhone($room, $actorId, '');
}
if ($actorType === Attendee::ACTOR_FEDERATED_USERS) {
return $this->getRemoteUser($actorId);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/Controller/CallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
namespace OCA\Talk\Controller;

use OCA\Talk\Config;
use OCA\Talk\Exceptions\DialOutFailedException;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Middleware\Attribute\RequireCallEnabled;
use OCA\Talk\Middleware\Attribute\RequireModeratorOrNoLobby;
Expand Down Expand Up @@ -207,7 +208,7 @@ public function ringAttendee(int $attendeeId): DataResponse {
* 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
Expand All @@ -231,6 +232,11 @@ public function sipDialOut(int $attendeeId): DataResponse {
$this->participantService->startDialOutRequest($this->dialOutService, $this->room, $attendeeId);
} catch (ParticipantNotFoundException) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
} catch (DialOutFailedException $e) {
return new DataResponse([
'error' => $e->getMessage(),
'message' => $e->getReadableError(),
], Http::STATUS_NOT_IMPLEMENTED);
} catch (\InvalidArgumentException) {
return new DataResponse([], Http::STATUS_NOT_IMPLEMENTED);
}
Expand Down
9 changes: 9 additions & 0 deletions lib/Controller/SignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,15 @@ public function getWelcomeMessage(int $serverId): DataResponse {
], Http::STATUS_INTERNAL_SERVER_ERROR);
}

$missingFeatures = $this->signalingManager->getSignalingServerMissingFeatures($response);
if (!empty($missingFeatures)) {
return new DataResponse([
'warning' => 'UPDATE_OPTIONAL',
'features' => $missingFeatures,
'version' => $data['version'] ?? '',
]);
}

return new DataResponse($data);
} catch (ConnectException $e) {
return new DataResponse(['error' => 'CAN_NOT_CONNECT'], Http::STATUS_INTERNAL_SERVER_ERROR);
Expand Down
39 changes: 39 additions & 0 deletions lib/Exceptions/DialOutFailedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


namespace OCA\Talk\Exceptions;

class DialOutFailedException extends \RuntimeException {
public function __construct(
string $errorCode,
protected string $readableError) {
parent::__construct($errorCode);
}

public function getReadableError(): string {
return $this->readableError;
}
}
14 changes: 13 additions & 1 deletion lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
use OCA\Talk\Events\SystemMessagesMultipleSentEvent;
use OCA\Talk\Events\UserJoinedRoomEvent;
use OCA\Talk\Exceptions\CannotReachRemoteException;
use OCA\Talk\Exceptions\DialOutFailedException;
use OCA\Talk\Exceptions\ForbiddenException;
use OCA\Talk\Exceptions\InvalidPasswordException;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
Expand Down Expand Up @@ -1193,10 +1194,13 @@ public function changeInCall(Room $room, Participant $participant, int $flags, b
$this->sessionMapper->update($session);
}

$attendee = $participant->getAttendee();
if ($flags !== Participant::FLAG_DISCONNECTED) {
$attendee = $participant->getAttendee();
$attendee->setLastJoinedCall($this->timeFactory->getTime());
$this->attendeeMapper->update($attendee);
} elseif ($attendee->getActorType() === Attendee::ACTOR_PHONES) {
$attendee->setCallId('');
$this->attendeeMapper->update($attendee);
}

if ($flags !== Participant::FLAG_DISCONNECTED) {
Expand Down Expand Up @@ -1237,6 +1241,7 @@ public function sendCallNotificationForAttendee(Room $room, Participant $current

/**
* @throws \InvalidArgumentException
* @throws DialOutFailedException
* @throws ParticipantNotFoundException
*/
public function startDialOutRequest(SIPDialOutService $dialOutService, Room $room, int $targetAttendeeId): void {
Expand All @@ -1260,6 +1265,13 @@ public function startDialOutRequest(SIPDialOutService $dialOutService, Room $roo
throw new \InvalidArgumentException('backend');
}

if ($dialOutResponse->dialOut->error->message) {
throw new DialOutFailedException(
$dialOutResponse->dialOut->error->code,
$dialOutResponse->dialOut->error->message,
);
}

$attendee->setCallId($dialOutResponse->dialOut->callId);
$this->attendeeMapper->update($attendee);
}
Expand Down
14 changes: 13 additions & 1 deletion lib/Signaling/BackendNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\ServerException;
use OC\Http\Client\Response;
use OCA\Talk\Config;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Session;
Expand Down Expand Up @@ -77,14 +78,25 @@ protected function doRequest(string $url, array $params, int $retries = 3): ?IRe
}

return $response;
} catch (ServerException | ConnectException $e) {
} catch (ConnectException $e) {
if ($retries > 1) {
$this->logger->error('Failed to send message to signaling server, ' . $retries . ' retries left!', ['exception' => $e]);
return $this->doRequest($url, $params, $retries - 1);
}

$this->logger->error('Failed to send message to signaling server, giving up!', ['exception' => $e]);
throw $e;
} catch (ServerException $e) {
if ($retries > 1) {
$this->logger->error('Failed to send message to signaling server, ' . $retries . ' retries left!', ['exception' => $e]);
return $this->doRequest($url, $params, $retries - 1);
}

$this->logger->error('Failed to send message to signaling server, giving up!', ['exception' => $e]);
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;
Expand Down
10 changes: 10 additions & 0 deletions lib/Signaling/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public function isCompatibleSignalingServer(IResponse $response): bool {
&& in_array('switchto', $features, true);
}

public function getSignalingServerMissingFeatures(IResponse $response): array {
$featureHeader = $response->getHeader(self::FEATURE_HEADER);
$features = explode(',', $featureHeader);
$features = array_map('trim', $features);

return array_values(array_diff([
'dialout',
], $features));
}

public function getSignalingServerLinkForConversation(?Room $room): string {
if ($this->talkConfig->getSignalingMode() === Config::SIGNALING_INTERNAL) {
return '';
Expand Down
48 changes: 44 additions & 4 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4616,7 +4616,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
Expand Down Expand Up @@ -4644,7 +4654,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
Expand Down Expand Up @@ -4672,7 +4692,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
Expand Down Expand Up @@ -4700,7 +4730,17 @@
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {}
"data": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"hark": "^1.2.3",
"leaflet": "^1.9.4",
"leaflet-defaulticon-compatibility": "^0.1.2",
"libphonenumber-js": "^1.10.48",
"lodash": "^4.17.21",
"mockconsole": "0.0.1",
"nextcloud-vue-collections": "^0.11.1",
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
6 changes: 3 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -703,18 +703,18 @@ export default {

// Parent to breakout
if (oldConversation.breakoutRoomMode !== CONVERSATION.BREAKOUT_ROOM_MODE.NOT_CONFIGURED
&& newConversation.objectType === 'room') {
&& newConversation.objectType === CONVERSATION.OBJECT_TYPE.BREAKOUT_ROOM) {
return true
}

// Breakout to parent
if (oldConversation.objectType === 'room'
if (oldConversation.objectType === CONVERSATION.OBJECT_TYPE.BREAKOUT_ROOM
&& newConversation.breakoutRoomMode !== CONVERSATION.BREAKOUT_ROOM_MODE.NOT_CONFIGURED) {
return true
}

// Breakout to breakout
return oldConversation.objectType === 'room' && newConversation.objectType === 'room'
return oldConversation.objectType === CONVERSATION.OBJECT_TYPE.BREAKOUT_ROOM && newConversation.objectType === CONVERSATION.OBJECT_TYPE.BREAKOUT_ROOM
}
},
}
Expand Down
Loading
Loading