diff --git a/docs/settings.md b/docs/settings.md index dddff1f6dbe..edc862f21db 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -126,7 +126,7 @@ Legend: | `call_recording_summary` | bool | `true` | No | 🖌️ | Whether call recordings should automatically be summarized when a transcription and summary provider is enabled. | | `call_recording_transcription` | bool | `false` | Yes | | Whether call recordings should automatically be transcribed when a transcription provider is enabled. | | `call_recording_summary_prompt` | string | `''` | No | | Instructions used by LLM to generate Talk call recording summaries | -| `sip_dialout` | string
`yes` or `no` | `no` | Yes | | SIP dial-out is allowed when a SIP bridge is configured | +| `sip_bridge_dialout` | bool | `false` | Yes | | SIP dial-out is allowed when a SIP bridge is configured | | `federation_enabled` | bool | `false` | Yes | | 🏗️ *Work in progress:* Whether or not federation with this instance is allowed | | `federation_incoming_enabled` | string
`1` or `0` | `1` | Yes | | 🏗️ *Work in progress:* Whether users of this instance can be invited to federated conversations | | `federation_outgoing_enabled` | string
`1` or `0` | `1` | Yes | | 🏗️ *Work in progress:* Whether users of this instance can invite federated users into conversations | diff --git a/lib/Capabilities.php b/lib/Capabilities.php index d1b2118ec74..8d4fda65650 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -294,7 +294,7 @@ public function getCapabilities(): array { // 'predefined-backgrounds-v2' => list, 'can-upload-background' => false, 'sip-enabled' => $this->talkConfig->isSIPConfigured(), - 'sip-dialout-enabled' => $this->talkConfig->isSIPDialOutEnabled(), + 'sip-dialout-enabled' => $this->appConfig->getAppValueBool(Config::SIP_BRIDGE_DIALOUT), 'default-phone-region' => $this->serverConfig->getSystemValueString('default_phone_region'), 'can-enable-sip' => false, 'start-without-media' => $this->talkConfig->getCallsStartWithoutMedia($user?->getUID()), diff --git a/lib/Config.php b/lib/Config.php index fa2ca1e1026..5f2cb691b94 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -106,6 +106,12 @@ class Config { public const string HOSTED_SIGNALING_SERVER_ACCOUNT = 'hosted_signaling_server_account'; public const string HOSTED_SIGNALING_SERVER_NONCE = 'hosted_signaling_server_nonce'; public const string HOSTED_SIGNALING_SERVER_ACCOUNT_ID = 'hosted_signaling_server_account_id'; + public const string SIP_BRIDGE_DIALIN_INFO = 'sip_bridge_dialin_info'; + public const string SIP_BRIDGE_DIALOUT_ANONYMOUS = 'sip_bridge_dialout_anonymous'; + public const string SIP_BRIDGE_DIALOUT_NUMBER = 'sip_bridge_dialout_number'; + public const string SIP_BRIDGE_DIALOUT_PREFIX = 'sip_bridge_dialout_prefix'; + public const string SIP_BRIDGE_SHARED_SECRET = 'sip_bridge_shared_secret'; + public const string SIP_BRIDGE_DIALOUT = 'sip_bridge_dialout'; /** * 1. Call recording, … @@ -177,8 +183,8 @@ public function getSIPGroups(): array { } public function isSIPConfigured(): bool { - return $this->getSIPSharedSecret() !== '' - && $this->getDialInInfo() !== ''; + return $this->appConfig->getAppValueString(self::SIP_BRIDGE_SHARED_SECRET) !== '' + && $this->appConfig->getAppValueString(self::SIP_BRIDGE_DIALIN_INFO) !== ''; } /** @@ -204,15 +210,7 @@ public function isBreakoutRoomsEnabled(): bool { } public function isConversationSubfoldersEnabled(): bool { - return $this->appConfig->getAppValueBool(self::CONVERSATION_SUBFOLDERS, true); - } - - public function getDialInInfo(): string { - return $this->config->getAppValue('spreed', 'sip_bridge_dialin_info'); - } - - public function getSIPSharedSecret(): string { - return $this->config->getAppValue('spreed', 'sip_bridge_shared_secret'); + return $this->appConfig->getAppValueBool(self::CONVERSATION_SUBFOLDERS); } public function canUserEnableSIP(IUser $user): bool { @@ -222,7 +220,7 @@ public function canUserEnableSIP(IUser $user): bool { $this->canEnableSIP[$user->getUID()] = false; - $allowedGroups = $this->getSIPGroups(); + $allowedGroups = $this->appConfig->getAppValueArray(self::ALLOWED_GROUPS_SIP); if (empty($allowedGroups)) { $this->canEnableSIP[$user->getUID()] = true; } else { @@ -234,17 +232,13 @@ public function canUserEnableSIP(IUser $user): bool { } public function canUserDialOutSIP(IUser $user): bool { - if (!$this->isSIPDialOutEnabled()) { + if (!$this->appConfig->getAppValueBool(Config::SIP_BRIDGE_DIALOUT)) { return false; } return $this->canUserEnableSIP($user); } - public function isSIPDialOutEnabled(): bool { - return $this->config->getAppValue('spreed', 'sip_dialout', 'no') !== 'no'; - } - public function getRecordingServers(): array { $recording = $this->appConfig->getAppValueArray(self::RECORDING_SERVERS); return $recording['servers'] ?? []; diff --git a/lib/ConfigLexicon.php b/lib/ConfigLexicon.php index 9b0094d151d..82e73f34dc3 100644 --- a/lib/ConfigLexicon.php +++ b/lib/ConfigLexicon.php @@ -214,6 +214,12 @@ public function getAppConfigs(): array { new Entry(Config::HOSTED_SIGNALING_SERVER_ACCOUNT, ValueType::ARRAY, [], definition: 'Account information of the hosted signaling server', flags: IAppConfig::FLAG_SENSITIVE, rename: 'hosted-signaling-server-account'), new Entry(Config::HOSTED_SIGNALING_SERVER_NONCE, ValueType::STRING, '', definition: 'Temporary nonce while configuring the hosted signaling server', flags: IAppConfig::FLAG_SENSITIVE, rename: 'hosted-signaling-server-nonce'), new Entry(Config::HOSTED_SIGNALING_SERVER_ACCOUNT_ID, ValueType::STRING, '', definition: 'Account identifier of the hosted signaling server', flags: IAppConfig::FLAG_SENSITIVE, rename: 'hosted-signaling-server-account-id'), + new Entry(Config::SIP_BRIDGE_DIALIN_INFO, ValueType::STRING, '', definition: 'Additional information added in the SIP dial-in invitation mail and sidebar', flags: IAppConfig::FLAG_SENSITIVE), + new Entry(Config::SIP_BRIDGE_DIALOUT_ANONYMOUS, ValueType::BOOL, false, definition: 'When set to true, all out-going SIP calls will be anonymous calls (CLIR)'), + new Entry(Config::SIP_BRIDGE_DIALOUT_NUMBER, ValueType::STRING, '', definition: 'Fallback phone number that is used as caller for out-going calls when the user has no phone-number configured (has to be E164 `+49123456789` formatted'), + new Entry(Config::SIP_BRIDGE_DIALOUT_PREFIX, ValueType::STRING, '+', definition: 'Deprecated: Only used for direct dial-in from older SIP bridges, which send phone numbers without this prefix', deprecated: true), + new Entry(Config::SIP_BRIDGE_SHARED_SECRET, ValueType::STRING, '', definition: 'Shared secret allowing the SIP bridge to authenticate on the Nextcloud server', flags: IAppConfig::FLAG_SENSITIVE), + new Entry(Config::SIP_BRIDGE_DIALOUT, ValueType::BOOL, false, definition: 'SIP dial-out is allowed when a SIP bridge is configured', rename: 'sip_dialout'), ]; } diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php index 0935ca32055..3e77a45d52e 100644 --- a/lib/Controller/CallController.php +++ b/lib/Controller/CallController.php @@ -461,10 +461,10 @@ public function sipDialOut(int $attendeeId): DataResponse { } $callerNumber = true; - if ($this->appConfig->getAppValueBool('sip_bridge_dialout_anonymous')) { + if ($this->appConfig->getAppValueBool(Config::SIP_BRIDGE_DIALOUT_ANONYMOUS)) { $callerNumber = false; - } elseif ($this->appConfig->getAppValueString('sip_bridge_dialout_number') !== '') { - $callerNumber = $this->appConfig->getAppValueString('sip_bridge_dialout_number'); + } elseif ($this->appConfig->getAppValueString(Config::SIP_BRIDGE_DIALOUT_NUMBER) !== '') { + $callerNumber = $this->appConfig->getAppValueString(Config::SIP_BRIDGE_DIALOUT_NUMBER); } // No elseif, so we have the fallback to sip_bridge_dialout_number when the caller is no user or doesn't have a number diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 2b863e433fa..ee26d8ad54a 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -208,9 +208,9 @@ protected function getTalkHashHeader(): array { $this->config->getAppValue('spreed', 'federation_enabled'), json_encode($this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_SIP)), $this->appConfig->getAppValueBool(Config::MATTERBRIDGE_ENABLED), - $this->config->getAppValue('spreed', 'sip_bridge_dialin_info'), - $this->config->getAppValue('spreed', 'sip_bridge_shared_secret'), $this->appConfig->getAppValueInt(Config::RECORDING_CONSENT), + $this->appConfig->getAppValueString(Config::SIP_BRIDGE_DIALIN_INFO), + $this->appConfig->getAppValueString(Config::SIP_BRIDGE_SHARED_SECRET), $this->appConfig->getAppValueBool(Config::CALL_RECORDING_TRANSCRIPTION), $this->appConfig->getAppValueBool(Config::CALL_RECORDING_SUMMARY), $this->config->getAppValue('theming', 'cachebuster', '1'), @@ -588,7 +588,7 @@ public function getNoteToSelfConversation(): DataResponse { private function validateSIPBridgeRequest(string $token): bool { $random = $this->request->getHeader('talk-sipbridge-random'); $checksum = $this->request->getHeader('talk-sipbridge-checksum'); - $secret = $this->talkConfig->getSIPSharedSecret(); + $secret = $this->appConfig->getAppValueString(Config::SIP_BRIDGE_SHARED_SECRET); return $this->checksumVerificationService->validateRequest($random, $checksum, $secret, $token); } @@ -843,8 +843,7 @@ public function createRoom( $sipEnabled = Webinary::SIP_DISABLED; } elseif ($sipEnabled !== Webinary::SIP_DISABLED && $this->forcedParameters->getForcedParameter(Parameter::SIP_ENABLED) === null - && (!$this->talkConfig->isSIPConfigured() - || !$this->talkConfig->canUserEnableSIP($user))) { + && (!$this->talkConfig->isSIPConfigured() || !$this->talkConfig->canUserEnableSIP($user))) { if ($sipEnabled === $this->defaultParameters->getParameters()[Parameter::SIP_ENABLED->value]) { // Clients send the administrator configured default value also when the // user did not request SIP themselves, so it is silently disabled instead. @@ -2743,7 +2742,7 @@ public function directDialIn(string $phoneNumber, string $caller): DataResponse 'token' => '[a-z0-9]{4,30}', ])] public function verifyDialOutNumber(string $number, array $options = []): DataResponse { - if (!$this->talkConfig->isSIPConfigured() || !$this->talkConfig->isSIPDialOutEnabled()) { + if (!$this->talkConfig->isSIPConfigured() || !$this->appConfig->getAppValueBool(Config::SIP_BRIDGE_DIALOUT)) { return new DataResponse(null, Http::STATUS_NOT_IMPLEMENTED); } @@ -2841,7 +2840,7 @@ public function createGuestByDialIn(): DataResponse { 'token' => '[a-z0-9]{4,30}', ])] public function rejectedDialOutRequest(string $callId, array $options = []): DataResponse { - if (!$this->talkConfig->isSIPConfigured() || !$this->talkConfig->isSIPDialOutEnabled()) { + if (!$this->talkConfig->isSIPConfigured() || !$this->appConfig->getAppValueBool(Config::SIP_BRIDGE_DIALOUT)) { return new DataResponse(null, Http::STATUS_NOT_IMPLEMENTED); } diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 4df2678b84c..20576ffc14d 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -9,6 +9,7 @@ namespace OCA\Talk\Controller; use OCA\Talk\AuditLog\Operation; +use OCA\Talk\Config; use OCA\Talk\Settings\BeforePreferenceSetEventListener; use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\ApiRoute; @@ -16,6 +17,7 @@ use OCP\AppFramework\Http\Attribute\OpenAPI; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; +use OCP\AppFramework\Services\IAppConfig; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IGroup; @@ -30,6 +32,7 @@ public function __construct( string $appName, IRequest $request, private readonly IConfig $config, + private readonly IAppConfig $appConfig, private readonly IGroupManager $groupManager, private readonly BeforePreferenceSetEventListener $preferenceListener, private readonly ?string $userId, @@ -89,11 +92,10 @@ public function setSIPSettings( } } - $sharedSecretChanged = $this->config->getAppValue('spreed', 'sip_bridge_shared_secret') !== $sharedSecret; - - $this->config->setAppValue('spreed', 'sip_bridge_groups', json_encode($groups)); - $this->config->setAppValue('spreed', 'sip_bridge_dialin_info', $dialInInfo); - $this->config->setAppValue('spreed', 'sip_bridge_shared_secret', $sharedSecret); + $sharedSecretChanged = $this->appConfig->getAppValueString(Config::SIP_BRIDGE_SHARED_SECRET) !== $sharedSecret; + $this->appConfig->setAppValueArray(Config::ALLOWED_GROUPS_SIP, $groups); + $this->appConfig->setAppValueString(Config::SIP_BRIDGE_DIALIN_INFO, $dialInInfo); + $this->appConfig->setAppValueString(Config::SIP_BRIDGE_SHARED_SECRET, $sharedSecret); $this->dispatcher->dispatchTyped(new CriticalActionPerformedEvent( 'SIP bridge settings were changed: groups "{sipGroups}", shared secret {sharedSecret}', diff --git a/lib/Controller/SignalingController.php b/lib/Controller/SignalingController.php index 9bddc815a13..21fdd081e63 100644 --- a/lib/Controller/SignalingController.php +++ b/lib/Controller/SignalingController.php @@ -37,6 +37,7 @@ use OCP\AppFramework\Http\Attribute\RequestHeader; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; +use OCP\AppFramework\Services\IAppConfig; use OCP\AppFramework\Utility\ITimeFactory; use OCP\DB\Exception; use OCP\EventDispatcher\IEventDispatcher; @@ -60,6 +61,7 @@ public function __construct( string $appName, IRequest $request, private readonly Config $talkConfig, + private readonly IAppConfig $appConfig, private readonly \OCA\Talk\Signaling\Manager $signalingManager, private readonly ISession $serverSession, private readonly TalkSession $session, @@ -119,7 +121,7 @@ private function validateRecordingBackendRequest(string $data): bool { private function validateSIPBridgeRequest(string $data): bool { $random = $this->request->getHeader('talk-sipbridge-random'); $checksum = $this->request->getHeader('talk-sipbridge-checksum'); - $secret = $this->talkConfig->getSIPSharedSecret(); + $secret = $this->appConfig->getAppValueString(Config::SIP_BRIDGE_SHARED_SECRET); try { return $this->checksumVerificationService->validateRequest($random, $checksum, $secret, $data); } catch (UnauthorizedException) { @@ -269,7 +271,7 @@ public function getSettings(string $token = ''): DataResponse { 'federation' => $this->getFederationSettings($room), 'stunservers' => $stun, 'turnservers' => $turn, - 'sipDialinInfo' => $this->talkConfig->isSIPConfigured() ? $this->talkConfig->getDialInInfo() : '', + 'sipDialinInfo' => $this->talkConfig->isSIPConfigured() ? $this->appConfig->getAppValueString(Config::SIP_BRIDGE_DIALIN_INFO) : '', ]; if ($signalingMode !== Config::SIGNALING_INTERNAL) { diff --git a/lib/GuestManager.php b/lib/GuestManager.php index bf8c41d1afc..4d186f40a91 100644 --- a/lib/GuestManager.php +++ b/lib/GuestManager.php @@ -20,6 +20,7 @@ use OCA\Talk\Service\ParticipantService; use OCA\Talk\Service\PollService; use OCA\Talk\Service\RoomService; +use OCP\AppFramework\Services\IAppConfig; use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; use OCP\IDateTimeZone; @@ -35,6 +36,7 @@ class GuestManager { public function __construct( private readonly Config $talkConfig, + private readonly IAppConfig $appConfig, private readonly IEmailValidator $emailValidator, private readonly IMailer $mailer, private readonly Defaults $defaults, @@ -284,7 +286,7 @@ public function sendEmailInvitation(Room $room, Participant $participant): void $template->addBodyText($this->l->t('You can also dial-in via phone with the following details')); $template->addBodyListItem( - $this->talkConfig->getDialInInfo(), + $this->appConfig->getAppValueString(Config::SIP_BRIDGE_DIALIN_INFO), $this->l->t('Dial-in information'), $this->url->getAbsoluteURL($this->url->imagePath('spreed', 'phone.png')) ); diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index cf1bb542d9b..86afd759667 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -461,15 +461,15 @@ protected function initRecording(): void { } protected function initSIPBridge(): void { - $groups = $this->getGroupDetailsArray($this->talkConfig->getSIPGroups(), 'sip_bridge_groups'); + $groups = $this->getGroupDetailsArray($this->appConfig->getAppValueArray(Config::ALLOWED_GROUPS_SIP), Config::ALLOWED_GROUPS_SIP); $this->initialState->provideInitialState('sip_bridge_groups', $groups); - $this->initialState->provideInitialState('sip_bridge_shared_secret', $this->talkConfig->getSIPSharedSecret()); - $this->initialState->provideInitialState('sip_bridge_dialin_info', $this->talkConfig->getDialInInfo()); - $this->initialState->provideInitialState('sip_bridge_dialout', $this->talkConfig->isSIPDialOutEnabled()); - $this->initialState->provideInitialState('sip_bridge_dialout_anonymous', $this->appConfig->getAppValueBool('sip_bridge_dialout_anonymous')); - $this->initialState->provideInitialState('sip_bridge_dialout_number', $this->serverConfig->getAppValue('spreed', 'sip_bridge_dialout_number', '')); - $this->initialState->provideInitialState('sip_bridge_dialout_prefix', $this->serverConfig->getAppValue('spreed', 'sip_bridge_dialout_prefix', '+')); + $this->initialState->provideInitialState('sip_bridge_shared_secret', $this->appConfig->getAppValueString(Config::SIP_BRIDGE_SHARED_SECRET)); + $this->initialState->provideInitialState('sip_bridge_dialin_info', $this->appConfig->getAppValueString(Config::SIP_BRIDGE_DIALIN_INFO)); + $this->initialState->provideInitialState('sip_bridge_dialout', $this->appConfig->getAppValueBool(Config::SIP_BRIDGE_DIALOUT)); + $this->initialState->provideInitialState('sip_bridge_dialout_anonymous', $this->appConfig->getAppValueBool(Config::SIP_BRIDGE_DIALOUT_ANONYMOUS)); + $this->initialState->provideInitialState('sip_bridge_dialout_number', $this->appConfig->getAppValueString(Config::SIP_BRIDGE_DIALOUT_NUMBER)); + $this->initialState->provideInitialState('sip_bridge_dialout_prefix', $this->appConfig->getAppValueString(Config::SIP_BRIDGE_DIALOUT_PREFIX)); } protected function getGroupDetailsArray(array $gids, string $configKey): array { diff --git a/lib/SetupCheck/SIPConfiguration.php b/lib/SetupCheck/SIPConfiguration.php index 21a06c460a5..a7497c182c5 100644 --- a/lib/SetupCheck/SIPConfiguration.php +++ b/lib/SetupCheck/SIPConfiguration.php @@ -42,8 +42,7 @@ public function run(): SetupResult { return SetupResult::success($this->l->t('Using the SIP functionality requires a High-performance backend.')); } - if ($this->talkConfig->getSIPSharedSecret() === '' - && $this->talkConfig->getDialInInfo() === '' + if (!$this->talkConfig->isSIPConfigured() && $this->appConfig->getAppValueInt(Config::FEATURE_HINTS_HIDDEN) < 34) { return SetupResult::info($this->l->t('No SIP backend configured')); } diff --git a/src/components/AdminSettings/SIPBridge.vue b/src/components/AdminSettings/SIPBridge.vue index 2fa0dcb5fe6..eb1da0d4db5 100644 --- a/src/components/AdminSettings/SIPBridge.vue +++ b/src/components/AdminSettings/SIPBridge.vue @@ -266,7 +266,7 @@ export default { dialInInfo: this.dialInInfo, }) if (this.currentSetup.dialOutEnabled !== this.dialOutEnabled) { - await OCP.AppConfig.setValue('spreed', 'sip_dialout', this.dialOutEnabled ? 'yes' : 'no') + await OCP.AppConfig.setValue('spreed', 'sip_bridge_dialout', this.dialOutEnabled.toString()) } if (this.currentSetup.dialOutAnonymous !== this.dialOutAnonymous) { await OCP.AppConfig.setValue('spreed', 'sip_bridge_dialout_anonymous', String(this.dialOutAnonymous)) diff --git a/tests/integration/features/callapi/sip-dialout.feature b/tests/integration/features/callapi/sip-dialout.feature index 800cf2023b5..5649246fb2b 100644 --- a/tests/integration/features/callapi/sip-dialout.feature +++ b/tests/integration/features/callapi/sip-dialout.feature @@ -11,7 +11,7 @@ Feature: callapi/sip-dialout | sip_bridge_dialin_info | +49-1234-567890 | | sip_bridge_shared_secret | 1234567890abcdef | | sip_bridge_groups | ["group1"] | - | sip_dialout | yes | + | sip_bridge_dialout| true | And user "participant1" creates room "room" (v4) | roomType | 3 | | roomName | room | diff --git a/tests/integration/features/conversation-4/classified.feature b/tests/integration/features/conversation-4/classified.feature index 4e6076c6c8d..2b1f04e7aee 100644 --- a/tests/integration/features/conversation-4/classified.feature +++ b/tests/integration/features/conversation-4/classified.feature @@ -155,7 +155,7 @@ Feature: conversation-4/classified | sip_bridge_dialin_info | +49-1234-567890 | | sip_bridge_shared_secret | 1234567890abcdef | | sip_bridge_groups | ["group1"] | - | sip_dialout | yes | + | sip_bridge_dialout | true | And user "participant1" creates room "classified" (v4) | roomType | 2 | | roomName | classified | diff --git a/tests/integration/features/conversation-5/sip-dialout.feature b/tests/integration/features/conversation-5/sip-dialout.feature index bd8f97ad96c..d1c20a5b4f4 100644 --- a/tests/integration/features/conversation-5/sip-dialout.feature +++ b/tests/integration/features/conversation-5/sip-dialout.feature @@ -10,7 +10,7 @@ Feature: conversation-5/sip-dialout | sip_bridge_dialin_info | +49-1234-567890 | | sip_bridge_shared_secret | 1234567890abcdef | | sip_bridge_groups | ["group1"] | - | sip_dialout | yes | + | sip_bridge_dialout| true | Given user "participant1" creates room "room" (v4) | roomType | 3 | | roomName | room | @@ -31,7 +31,7 @@ Feature: conversation-5/sip-dialout | sip_bridge_dialin_info | +49-1234-567890 | | sip_bridge_shared_secret | 1234567890abcdef | | sip_bridge_groups | ["group1"] | - | sip_dialout | yes | + | sip_bridge_dialout| true | Given user "participant2" creates room "room" (v4) | roomType | 3 | | roomName | room | diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php index 768025f9d58..560e1dfeb31 100644 --- a/tests/php/CapabilitiesTest.php +++ b/tests/php/CapabilitiesTest.php @@ -381,6 +381,8 @@ public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCrea ->willReturnMap([ ['backgrounds_default_for_users', true, true], ['backgrounds_upload_users', true, true], + ['sip_bridge_dialout', false], + ['sip_bridge_dialout_anonymous', false], ]); $this->appConfig->expects($this->any())->method('getAppValueInt') diff --git a/tests/php/Controller/SettingsControllerTest.php b/tests/php/Controller/SettingsControllerTest.php index 299ecb8c7e4..ce4044c1549 100644 --- a/tests/php/Controller/SettingsControllerTest.php +++ b/tests/php/Controller/SettingsControllerTest.php @@ -8,8 +8,10 @@ namespace OCA\Talk\Tests\php\Controller; +use OCA\Talk\Config; use OCA\Talk\Controller\SettingsController; use OCA\Talk\Settings\BeforePreferenceSetEventListener; +use OCP\AppFramework\Services\IAppConfig; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IGroup; @@ -22,6 +24,7 @@ class SettingsControllerTest extends TestCase { protected IConfig&MockObject $config; + protected IAppConfig&MockObject $appConfig; protected IGroupManager&MockObject $groupManager; protected IEventDispatcher&MockObject $dispatcher; protected SettingsController $controller; @@ -30,12 +33,14 @@ public function setUp(): void { parent::setUp(); $this->config = $this->createMock(IConfig::class); + $this->appConfig = $this->createMock(IAppConfig::class); $this->groupManager = $this->createMock(IGroupManager::class); $this->dispatcher = $this->createMock(IEventDispatcher::class); $this->controller = new SettingsController( 'spreed', $this->createMock(IRequest::class), $this->config, + $this->appConfig, $this->groupManager, $this->createMock(BeforePreferenceSetEventListener::class), 'admin', @@ -58,7 +63,10 @@ public function testSetSIPSettingsLogsCriticalAction(string $oldSecret, string $ ['sip-users', $group], ['unknown', null], ]); - $this->config->method('getAppValue')->with('spreed', 'sip_bridge_shared_secret')->willReturn($oldSecret); + + $this->appConfig->method('getAppValueString')->willReturnMap([ + [Config::SIP_BRIDGE_SHARED_SECRET, $oldSecret], + ]); $this->dispatcher->expects($this->once()) ->method('dispatchTyped') diff --git a/tests/php/Controller/SignalingControllerTest.php b/tests/php/Controller/SignalingControllerTest.php index 773ecd4cd1d..34a05478182 100644 --- a/tests/php/Controller/SignalingControllerTest.php +++ b/tests/php/Controller/SignalingControllerTest.php @@ -138,6 +138,7 @@ private function recreateSignalingController() { 'spreed', $this->request, $this->config, + $this->appConfig, $this->signalingManager, $this->serverSession, $this->session, @@ -1375,7 +1376,7 @@ public function testLeaveRoomWithOldSession(): void { $dbConnection, \OCP\Server::get(IConfig::class), $this->createMock(Config::class), - $this->appConfig, + $this->createMock(IAppConfig::class), \OCP\Server::get(IAppManager::class), \OCP\Server::get(AttendeeMapper::class), \OCP\Server::get(SessionMapper::class), @@ -1461,8 +1462,8 @@ private function sipBridgeChecksum(string $data, string $random): string { } private function setUpSIPBridgeConfig(): void { - $this->config = $this->createMock(Config::class); - $this->config->method('getSIPSharedSecret')->willReturn(self::SIP_BRIDGE_SECRET); + $this->appConfig = $this->createMock(IAppConfig::class); + $this->appConfig->method('getAppValueString')->with(Config::SIP_BRIDGE_SHARED_SECRET)->willReturn(self::SIP_BRIDGE_SECRET); $this->userId = null; $this->recreateSignalingController(); } @@ -1510,12 +1511,20 @@ public function testGetSettingsSIPBridgeShortRandom(): void { public function testGetSettingsSIPBridgeValidNoToken(): void { $this->config = $this->createMock(Config::class); - $this->config->method('getSIPSharedSecret')->willReturn(self::SIP_BRIDGE_SECRET); + $this->appConfig = $this->createMock(IAppConfig::class); $this->config->method('getStunServers')->willReturn([]); $this->config->method('getTurnSettings')->willReturn([]); $this->config->method('getSignalingMode')->willReturn(Config::SIGNALING_INTERNAL); $this->config->method('getHideSignalingWarning')->willReturn(false); - $this->config->method('isSIPConfigured')->willReturn(false); + + // when Config::SIP_BRIDGE_DIALIN_INFO is empty, SIP is not configured + $this->appConfig + ->method('getAppValueString') + ->willReturnCallback(fn (string $key): string => match ($key) { + Config::SIP_BRIDGE_DIALIN_INFO => '', + Config::SIP_BRIDGE_SHARED_SECRET => self::SIP_BRIDGE_SECRET, + }); + $this->userId = null; $this->recreateSignalingController(); diff --git a/tests/php/GuestManagerTest.php b/tests/php/GuestManagerTest.php index e708e2ef3ac..213897e31aa 100644 --- a/tests/php/GuestManagerTest.php +++ b/tests/php/GuestManagerTest.php @@ -17,6 +17,7 @@ use OCA\Talk\Service\ParticipantService; use OCA\Talk\Service\PollService; use OCA\Talk\Service\RoomService; +use OCP\AppFramework\Services\IAppConfig; use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; use OCP\IDateTimeZone; @@ -32,6 +33,7 @@ class GuestManagerTest extends TestCase { protected Config&MockObject $talkConfig; + protected IAppConfig&MockObject $appConfig; protected IEmailValidator&MockObject $emailValidator; protected IMailer&MockObject $mailer; protected Defaults&MockObject $defaults; @@ -48,6 +50,7 @@ class GuestManagerTest extends TestCase { public function setUp(): void { parent::setUp(); $this->talkConfig = $this->createMock(Config::class); + $this->appConfig = $this->createMock(IAppConfig::class); $this->emailValidator = $this->createMock(IEmailValidator::class); $this->mailer = $this->createMock(IMailer::class); $this->defaults = $this->createMock(Defaults::class); @@ -67,6 +70,7 @@ public function getGuestManager(array $methods = []): GuestManager|MockObject { return $this->getMockBuilder(GuestManager::class) ->setConstructorArgs([ $this->talkConfig, + $this->appConfig, $this->emailValidator, $this->mailer, $this->defaults, @@ -86,6 +90,7 @@ public function getGuestManager(array $methods = []): GuestManager|MockObject { return new GuestManager( $this->talkConfig, + $this->appConfig, $this->emailValidator, $this->mailer, $this->defaults, diff --git a/tests/php/Service/InvitationServiceTest.php b/tests/php/Service/InvitationServiceTest.php index 631e8484c7d..f8fce7fb5b4 100644 --- a/tests/php/Service/InvitationServiceTest.php +++ b/tests/php/Service/InvitationServiceTest.php @@ -14,6 +14,7 @@ use OCA\Talk\Service\InvitationService; use OCA\Talk\Service\ParticipantService; use OCP\App\IAppManager; +use OCP\AppFramework\Services\IAppConfig; use OCP\Federation\ICloudId; use OCP\Federation\ICloudIdManager; use OCP\IConfig; @@ -35,6 +36,7 @@ class InvitationServiceTest extends TestCase { protected ParticipantService&MockObject $participantService; protected IConfig&MockObject $serverConfig; protected Config&MockObject $talkConfig; + protected IAppConfig&MockObject $appConfig; protected IEmailValidator&MockObject $emailValidator; protected InvitationService $service; @@ -50,6 +52,7 @@ public function setUp(): void { $this->participantService = $this->createMock(ParticipantService::class); $this->serverConfig = $this->createMock(IConfig::class); $this->talkConfig = $this->createMock(Config::class); + $this->appConfig = $this->createMock(IAppConfig::class); $this->emailValidator = $this->createMock(IEmailValidator::class); $this->service = new InvitationService( @@ -68,7 +71,6 @@ public function setUp(): void { public function testPhoneInvitationsAreRejectedWhenCreatingClassifiedConversation(): void { $currentUser = $this->createStub(IUser::class); - // SIP is fully available, only the classified flag must reject the number $this->talkConfig->method('isSIPConfigured')->willReturn(true); $this->talkConfig->method('canUserDialOutSIP')->willReturn(true); $this->phoneNumberUtil->expects(self::never()) @@ -89,7 +91,15 @@ public function testPhoneInvitationsAreRejectedForClassifiedRoom(): void { $currentUser = $this->createStub(IUser::class); $room = $this->createMock(Room::class); $room->method('isClassified')->willReturn(true); - $this->talkConfig->method('isSIPConfigured')->willReturn(true); + + // when Config::SIP_BRIDGE_DIALIN_INFO and Config::SIP_BRIDGE_SECRET both are not empty, SIP is configured + $this->appConfig + ->method('getAppValueString') + ->willReturnCallback(fn (string $key): string => match ($key) { + Config::SIP_BRIDGE_DIALIN_INFO => Config::SIP_BRIDGE_DIALIN_INFO, + Config::SIP_BRIDGE_SHARED_SECRET => Config::SIP_BRIDGE_SHARED_SECRET, + }); + $this->talkConfig->method('canUserDialOutSIP')->willReturn(true); $this->phoneNumberUtil->expects(self::never()) ->method('convertToStandardFormat');