From 4cd91910c6d34775532e05ec14e6030261cb74f4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 13 Oct 2023 14:54:29 +0200 Subject: [PATCH] fix(docs): Add capability configs for all the SIP states Signed-off-by: Joas Schilling --- docs/capabilities.md | 4 ++++ lib/Capabilities.php | 7 +++++++ tests/php/CapabilitiesTest.php | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/docs/capabilities.md b/docs/capabilities.md index 567095c37c43..edbb59746d15 100644 --- a/docs/capabilities.md +++ b/docs/capabilities.md @@ -131,5 +131,9 @@ * `session-state` - Sessions can mark themselves as inactive, so the participant receives notifications again * `note-to-self` - Support for "Note-to-self" conversation exists * `recording-consent` - Whether admins and moderators can require recording consent before joining a call +* `sip-support-dialout` - Whether admins can enable SIP dial-out * `config => chat => has-translation-providers` - When true, translation tuples can be loaded from the [OCS Translation API](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-translation-api.html#get-available-translation-options). * `config => call => recording-consent` - Whether users need to consent into call recording before joining a call (see [constants list](constants.md#recording-consent-required)) +* `config => call => sip-enabled` - Whether SIP is configured on the server allowing for SIP dial-in +* `config => call => sip-dialout-enabled` - Whether SIP dial-out is configured on the server, additionally requires `config => call => sip-enabled` +* `config => call => can-enable-sip` - Whether the current user is a member of the groups that are allowed to enable SIP dial-in on a conversation or use SIP dial-out diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 80c9b6527a0d..a1b573ae68a4 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -70,6 +70,9 @@ public function __construct( * supported-reactions: string[], * predefined-backgrounds: string[], * can-upload-background: bool, + * sip-enabled: bool, + * sip-dialout-enabled: bool, + * can-enable-sip: bool, * }, * chat: array{ * max-length: int, @@ -177,6 +180,8 @@ public function getCapabilities(): array { 'recording' => $this->talkConfig->isRecordingEnabled(), 'recording-consent' => $this->talkConfig->recordingConsentRequired(), 'supported-reactions' => ['❤️', '🎉', '👏', '👍', '👎', '😂', '🤩', '🤔', '😲', '😥'], + 'sip-enabled' => $this->talkConfig->isSIPConfigured(), + 'sip-dialout-enabled' => $this->talkConfig->isSIPDialOutEnabled(), ], 'chat' => [ 'max-length' => ChatManager::MAX_CHAT_LENGTH, @@ -260,8 +265,10 @@ public function getCapabilities(): array { $quota = Util::computerFileSize($quota); } $capabilities['config']['call']['can-upload-background'] = $quota === 'none' || $quota > 0; + $capabilities['config']['call']['can-enable-sip'] = $this->talkConfig->canUserEnableSIP($user); } else { $capabilities['config']['call']['can-upload-background'] = false; + $capabilities['config']['call']['can-enable-sip'] = false; } return [ diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php index 4f82ee8a1adb..c21c0a711440 100644 --- a/tests/php/CapabilitiesTest.php +++ b/tests/php/CapabilitiesTest.php @@ -142,6 +142,7 @@ public function setUp(): void { 'session-state', 'note-to-self', 'recording-consent', + 'sip-support-dialout', 'message-expiration', 'reactions', ]; @@ -193,6 +194,8 @@ public function testGetCapabilitiesGuest(): void { 'recording' => false, 'recording-consent' => 0, 'supported-reactions' => ['❤️', '🎉', '👏', '👍', '👎', '😂', '🤩', '🤔', '😲', '😥'], + 'sip-enabled' => false, + 'sip-dialout-enabled' => false, 'predefined-backgrounds' => [ '1_office.jpg', '2_home.jpg', @@ -204,6 +207,7 @@ public function testGetCapabilitiesGuest(): void { '8_space_station.jpg', ], 'can-upload-background' => false, + 'can-enable-sip' => false, ], 'chat' => [ 'max-length' => 32000, @@ -318,6 +322,8 @@ public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCrea 'recording' => false, 'recording-consent' => 0, 'supported-reactions' => ['❤️', '🎉', '👏', '👍', '👎', '😂', '🤩', '🤔', '😲', '😥'], + 'sip-enabled' => false, + 'sip-dialout-enabled' => false, 'predefined-backgrounds' => [ '1_office.jpg', '2_home.jpg', @@ -329,6 +335,7 @@ public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCrea '8_space_station.jpg', ], 'can-upload-background' => $canUpload, + 'can-enable-sip' => false, ], 'chat' => [ 'max-length' => 32000,