From e009abdd54030b654044f567fb88873b6365dc42 Mon Sep 17 00:00:00 2001 From: Pablo Zmdl Date: Mon, 19 Jan 2026 12:03:38 +0100 Subject: [PATCH] Make `isTalkEnabled` an attribute Signed-off-by: Pablo Zmdl --- php/public/index.php | 2 +- php/src/ContainerDefinitionFetcher.php | 4 ++-- .../Controller/ConfigurationController.php | 6 +----- php/src/Data/ConfigurationManager.php | 20 +++++-------------- php/src/Docker/DockerActionManager.php | 2 +- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/php/public/index.php b/php/public/index.php index adfd72d5..0481aceb 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -113,7 +113,7 @@ $app->get('/containers', function (Request $request, Response $response, array $ 'is_clamav_enabled' => $configurationManager->isClamavEnabled, 'is_onlyoffice_enabled' => $configurationManager->isOnlyofficeEnabled, 'is_collabora_enabled' => $configurationManager->isCollaboraEnabled, - 'is_talk_enabled' => $configurationManager->isTalkEnabled(), + 'is_talk_enabled' => $configurationManager->isTalkEnabled, 'borg_restore_password' => $configurationManager->GetBorgRestorePassword(), 'daily_backup_time' => $configurationManager->GetDailyBackupTime(), 'is_daily_backup_running' => $configurationManager->isDailyBackupRunning(), diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index e4e27f69..9635c8cf 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -71,7 +71,7 @@ readonly class ContainerDefinitionFetcher { $entry['image'] = 'ghcr.io/nextcloud-releases/aio-collabora-online'; } } elseif ($entry['container_name'] === 'nextcloud-aio-talk') { - if (!$this->configurationManager->isTalkEnabled()) { + if (!$this->configurationManager->isTalkEnabled) { continue; } } elseif ($entry['container_name'] === 'nextcloud-aio-talk-recording') { @@ -180,7 +180,7 @@ readonly class ContainerDefinitionFetcher { continue; } } elseif ($value === 'nextcloud-aio-talk') { - if (!$this->configurationManager->isTalkEnabled()) { + if (!$this->configurationManager->isTalkEnabled) { continue; } } elseif ($value === 'nextcloud-aio-talk-recording') { diff --git a/php/src/Controller/ConfigurationController.php b/php/src/Controller/ConfigurationController.php index 56621eee..75ec29ae 100644 --- a/php/src/Controller/ConfigurationController.php +++ b/php/src/Controller/ConfigurationController.php @@ -89,11 +89,7 @@ readonly class ConfigurationController { $this->configurationManager->isOnlyofficeEnabled = false; } $this->configurationManager->isClamavEnabled = isset($request->getParsedBody()['clamav']); - if (isset($request->getParsedBody()['talk'])) { - $this->configurationManager->SetTalkEnabledState(1); - } else { - $this->configurationManager->SetTalkEnabledState(0); - } + $this->configurationManager->isTalkEnabled = isset($request->getParsedBody()['talk']); if (isset($request->getParsedBody()['talk-recording'])) { $this->configurationManager->SetTalkRecordingEnabledState(1); } else { diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 165f9c44..648d04c3 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -83,6 +83,11 @@ class ConfigurationManager set { $this->set('isCollaboraEnabled', $value); } } + public bool $isTalkEnabled { + get => $this->get('isTalkEnabled', true); + set { $this->set('isTalkEnabled', $value); } + } + public function GetConfig() : array { if ($this->config === [] && file_exists(DataConst::GetConfigFile())) @@ -253,21 +258,6 @@ class ConfigurationManager $this->WriteConfig($config); } - public function isTalkEnabled() : bool { - $config = $this->GetConfig(); - if (isset($config['isTalkEnabled']) && $config['isTalkEnabled'] === 0) { - return false; - } else { - return true; - } - } - - public function SetTalkEnabledState(int $value) : void { - $config = $this->GetConfig(); - $config['isTalkEnabled'] = $value; - $this->WriteConfig($config); - } - public function isTalkRecordingEnabled() : bool { if (!$this->isTalkEnabled()) { return false; diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 7cb20ad6..313de7b0 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -575,7 +575,7 @@ readonly class DockerActionManager { 'TALK_RECORDING_ENABLED' => $this->configurationManager->isTalkRecordingEnabled() ? 'yes' : '', 'ONLYOFFICE_ENABLED' => $this->configurationManager->isOnlyofficeEnabled ? 'yes' : '', 'COLLABORA_ENABLED' => $this->configurationManager->isCollaboraEnabled ? 'yes' : '', - 'TALK_ENABLED' => $this->configurationManager->isTalkEnabled() ? 'yes' : '', + 'TALK_ENABLED' => $this->configurationManager->isTalkEnabled ? 'yes' : '', 'UPDATE_NEXTCLOUD_APPS' => ($this->configurationManager->isDailyBackupRunning() && $this->configurationManager->areAutomaticUpdatesEnabled()) ? 'yes' : '', 'TIMEZONE' => $this->configurationManager->GetTimezone() === '' ? 'Etc/UTC' : $this->configurationManager->GetTimezone(), 'COLLABORA_DICTIONARIES' => $this->configurationManager->GetCollaboraDictionaries() === '' ? 'de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru' : $this->configurationManager->GetCollaboraDictionaries(),