diff --git a/lib/ConfigLexicon.php b/lib/ConfigLexicon.php index d5367ee8324..c2396049666 100644 --- a/lib/ConfigLexicon.php +++ b/lib/ConfigLexicon.php @@ -226,6 +226,7 @@ public function getAppConfigs(): array { 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_DIALIN_DEFAULT, ValueType::INT, 0, definition: 'Default value of SIP dial-in when creating new conversations'), 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), diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index d2721066bfe..fd7614ef3b4 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -189,7 +189,7 @@ public function __construct( protected function getTalkHashHeader(): array { $values = [ $this->config->getSystemValueString('version'), - $this->config->getAppValue('spreed', 'installed_version'), + $this->appConfig->getAppValueString('installed_version'), json_encode($this->appConfig->getAppValueArray(Config::STUN_SERVERS)), json_encode($this->appConfig->getAppValueArray(Config::TURN_SERVERS)), json_encode($this->appConfig->getAppValueArray(Config::SIGNALING_SERVERS)), diff --git a/lib/Listener/GroupDeletedListener.php b/lib/Listener/GroupDeletedListener.php index 919352700d4..cbfc775140b 100644 --- a/lib/Listener/GroupDeletedListener.php +++ b/lib/Listener/GroupDeletedListener.php @@ -13,18 +13,16 @@ use OCA\Talk\Manager; use OCA\Talk\Model\Attendee; use OCA\Talk\Service\ParticipantService; +use OCP\AppFramework\Services\IAppConfig; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\Group\Events\GroupDeletedEvent; -use OCP\IAppConfig; -use OCP\IConfig; /** * @template-implements IEventListener */ class GroupDeletedListener implements IEventListener { public function __construct( - private readonly IConfig $config, private readonly Manager $manager, private readonly ParticipantService $participantService, private readonly IAppConfig $appConfig, @@ -54,12 +52,10 @@ public function handle(Event $event): void { } protected function removeGroupFromConfig(string $configKey, string $removeGroupId): void { - $json = $this->config->getAppValue('spreed', $configKey, '[]'); - $array = json_decode($json, true); - $gids = \is_array($array) ? $array : []; + $gids = $this->appConfig->getAppValueArray($configKey); $gids = array_filter($gids, static fn ($gid) => $gid !== $removeGroupId); - $this->config->setAppValue('spreed', $configKey, json_encode($gids)); + $this->appConfig->setAppValueArray($configKey, $gids); } } diff --git a/lib/Manager.php b/lib/Manager.php index 5f681662c75..8ec2179278d 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -1267,13 +1267,11 @@ public function createRoom( } } if ($sipEnabled === null) { - $default = $this->config->getAppValue('spreed', 'sip_dialin_default', 'none'); - if ($default !== 'none') { - $default = (int)$default; - if (in_array($default, [Webinary::SIP_DISABLED, Webinary::SIP_ENABLED, Webinary::SIP_ENABLED_NO_PIN], true)) { - $sipEnabled = $default; - } + $default = $this->appConfig->getAppValueInt(Config::SIP_DIALIN_DEFAULT); + if (in_array($default, [Webinary::SIP_DISABLED, Webinary::SIP_ENABLED, Webinary::SIP_ENABLED_NO_PIN], true)) { + $sipEnabled = $default; } + } if ($sipEnabled !== null) { $insert->setValue('sip_enabled', $insert->createNamedParameter($sipEnabled, IQueryBuilder::PARAM_INT)); diff --git a/lib/Migration/ClearResourceAccessCache.php b/lib/Migration/ClearResourceAccessCache.php index 79a29bd4587..617fc05ac7e 100644 --- a/lib/Migration/ClearResourceAccessCache.php +++ b/lib/Migration/ClearResourceAccessCache.php @@ -9,8 +9,8 @@ namespace OCA\Talk\Migration; use OCA\Talk\Collaboration\Resources\ConversationProvider; +use OCP\AppFramework\Services\IAppConfig; use OCP\Collaboration\Resources\IManager; -use OCP\IConfig; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; @@ -18,7 +18,7 @@ class ClearResourceAccessCache implements IRepairStep { protected const INVALIDATIONS = 1; public function __construct( - private readonly IConfig $config, + private readonly IAppConfig $appConfig, private readonly IManager $manager, private readonly ConversationProvider $provider, ) { @@ -31,7 +31,7 @@ public function getName(): string { #[\Override] public function run(IOutput $output): void { - $invalidatedCache = (int)$this->config->getAppValue('spreed', 'project_access_invalidated', '0'); + $invalidatedCache = $this->appConfig->getAppValueInt('project_access_invalidated', 0); if ($invalidatedCache === self::INVALIDATIONS) { $output->info('Invalidation not required'); @@ -39,6 +39,6 @@ public function run(IOutput $output): void { } $this->manager->invalidateAccessCacheForProvider($this->provider); - $this->config->setAppValue('spreed', 'project_access_invalidated', (string)self::INVALIDATIONS); + $this->appConfig->setAppValueInt('project_access_invalidated', self::INVALIDATIONS); } } diff --git a/lib/Migration/Version14000Date20220217115327.php b/lib/Migration/Version14000Date20220217115327.php index b8641394fb9..252a071628e 100644 --- a/lib/Migration/Version14000Date20220217115327.php +++ b/lib/Migration/Version14000Date20220217115327.php @@ -9,7 +9,7 @@ namespace OCA\Talk\Migration; use Closure; -use OCP\IConfig; +use OCP\AppFramework\Services\IAppConfig; use OCP\Migration\Attributes\DataCleansing; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; @@ -18,7 +18,7 @@ class Version14000Date20220217115327 extends SimpleMigrationStep { public function __construct( - private readonly IConfig $config, + private readonly IAppConfig $appConfig, ) { } @@ -29,6 +29,6 @@ public function __construct( */ #[\Override] public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - $this->config->deleteAppValue('spreed', 'hosted-signaling-server-account-last-checked'); + $this->appConfig->deleteAppValue('hosted-signaling-server-account-last-checked'); } } diff --git a/lib/Migration/Version2000Date20171026140256.php b/lib/Migration/Version2000Date20171026140256.php index 63bf0091ba8..8a05bfc2dae 100644 --- a/lib/Migration/Version2000Date20171026140256.php +++ b/lib/Migration/Version2000Date20171026140256.php @@ -8,8 +8,8 @@ namespace OCA\Talk\Migration; +use OCP\AppFramework\Services\IAppConfig; use OCP\DB\QueryBuilder\IQueryBuilder; -use OCP\IConfig; use OCP\IDBConnection; use OCP\IGroupManager; use OCP\Migration\Attributes\DataCleansing; @@ -21,7 +21,7 @@ class Version2000Date20171026140256 extends SimpleMigrationStep { public function __construct( private readonly IDBConnection $connection, - private readonly IConfig $config, + private readonly IAppConfig $appConfig, private readonly IGroupManager $groupManager, ) { } @@ -34,7 +34,7 @@ public function __construct( */ #[\Override] public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { + if (version_compare($this->appConfig->getAppValueString('installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; } diff --git a/lib/Migration/Version2000Date20171026140257.php b/lib/Migration/Version2000Date20171026140257.php index 6da95b8c2f3..426c3f807a9 100644 --- a/lib/Migration/Version2000Date20171026140257.php +++ b/lib/Migration/Version2000Date20171026140257.php @@ -11,7 +11,6 @@ use OCA\Talk\Config; use OCP\AppFramework\Services\IAppConfig; use OCP\DB\QueryBuilder\IQueryBuilder; -use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\Attributes\DataCleansing; use OCP\Migration\IOutput; @@ -26,7 +25,6 @@ class Version2000Date20171026140257 extends SimpleMigrationStep { public function __construct( private readonly IDBConnection $connection, - private readonly IConfig $config, private readonly IAppConfig $appConfig, private readonly ISecureRandom $secureRandom, ) { @@ -41,7 +39,7 @@ public function __construct( */ #[\Override] public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { + if (version_compare($this->appConfig->getAppValueString('installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; } diff --git a/lib/Migration/Version2001Date20170707115443.php b/lib/Migration/Version2001Date20170707115443.php index c0463c15e80..60e5658a112 100644 --- a/lib/Migration/Version2001Date20170707115443.php +++ b/lib/Migration/Version2001Date20170707115443.php @@ -10,10 +10,10 @@ use OCA\Talk\Participant; use OCA\Talk\Room; +use OCP\AppFramework\Services\IAppConfig; use OCP\DB\ISchemaWrapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\Types; -use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\Attributes\AddColumn; use OCP\Migration\Attributes\ColumnType; @@ -27,7 +27,7 @@ class Version2001Date20170707115443 extends SimpleMigrationStep { public function __construct( private readonly IDBConnection $db, - private readonly IConfig $config, + private readonly IAppConfig $appConfig, ) { } @@ -63,7 +63,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op */ #[\Override] public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { + if (version_compare($this->appConfig->getAppValueString('installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; } diff --git a/lib/Migration/Version2001Date20171026134605.php b/lib/Migration/Version2001Date20171026134605.php index 98ca37b934e..fdfee784fab 100644 --- a/lib/Migration/Version2001Date20171026134605.php +++ b/lib/Migration/Version2001Date20171026134605.php @@ -10,10 +10,10 @@ use Doctrine\DBAL\Exception\InvalidFieldNameException; use Doctrine\DBAL\Exception\TableNotFoundException; +use OCP\AppFramework\Services\IAppConfig; use OCP\DB\ISchemaWrapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\Types; -use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\Attributes\CreateTable; use OCP\Migration\Attributes\DataCleansing; @@ -31,7 +31,7 @@ class Version2001Date20171026134605 extends SimpleMigrationStep { public function __construct( private readonly IDBConnection $connection, - private readonly IConfig $config, + private readonly IAppConfig $appConfig, ) { } @@ -152,7 +152,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op */ #[\Override] public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { + if (version_compare($this->appConfig->getAppValueString('installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; } diff --git a/lib/Migration/Version2001Date20180103144447.php b/lib/Migration/Version2001Date20180103144447.php index 2231df64892..67a3b05846c 100644 --- a/lib/Migration/Version2001Date20180103144447.php +++ b/lib/Migration/Version2001Date20180103144447.php @@ -8,9 +8,9 @@ namespace OCA\Talk\Migration; +use OCP\AppFramework\Services\IAppConfig; use OCP\DB\ISchemaWrapper; use OCP\DB\Types; -use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\Attributes\AddColumn; use OCP\Migration\Attributes\ColumnType; @@ -32,7 +32,7 @@ class Version2001Date20180103144447 extends SimpleMigrationStep { public function __construct( private readonly IDBConnection $connection, - private readonly IConfig $config, + private readonly IAppConfig $appConfig, ) { } @@ -108,7 +108,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op */ #[\Override] public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { + if (version_compare($this->appConfig->getAppValueString('installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; } diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index 83e237c7ccb..15137df3177 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -69,9 +69,9 @@ public function getForm(): TemplateResponse { } protected function initGeneralSettings(): void { - $this->initialState->provideInitialState(Config::DEFAULT_GROUP_NOTIFICATION, $this->appConfig->getAppValueInt(Config::DEFAULT_GROUP_NOTIFICATION)); - $this->initialState->provideInitialState(Config::CONVERSATIONS_FILES, (int)$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES)); - $this->initialState->provideInitialState(Config::CONVERSATIONS_FILES_PUBLIC_SHARES, (int)$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES_PUBLIC_SHARES)); + $this->initialState->provideInitialState('default_group_notification', $this->appConfig->getAppValueInt(Config::DEFAULT_GROUP_NOTIFICATION)); + $this->initialState->provideInitialState('conversations_files', (int)$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES)); + $this->initialState->provideInitialState('conversations_files_public_shares', (int)$this->appConfig->getAppValueBool(Config::CONVERSATIONS_FILES_PUBLIC_SHARES)); $this->initialState->provideInitialState('valid_apache_php_configuration', $this->validApachePHPConfiguration()); } @@ -486,7 +486,7 @@ protected function getGroupDetailsArray(array $gids, string $configKey): array { if (count($gids) !== count($groups)) { $gids = array_map(static fn (array $group) => $group['id'], $groups); - $this->serverConfig->setAppValue('spreed', $configKey, json_encode($gids)); + $this->appConfig->setAppValueArray($configKey, $gids); } return $groups;