Make isClamavEnabled an attribute

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
Pablo Zmdl 2026-01-19 12:01:53 +01:00
parent bebae7069b
commit f8a244bee2
5 changed files with 10 additions and 24 deletions

View file

@ -110,7 +110,7 @@ $app->get('/containers', function (Request $request, Response $response, array $
'last_backup_time' => $configurationManager->GetLastBackupTime(),
'backup_times' => $configurationManager->GetBackupTimes(),
'current_channel' => $dockerActionManager->GetCurrentChannel(),
'is_clamav_enabled' => $configurationManager->isClamavEnabled(),
'is_clamav_enabled' => $configurationManager->isClamavEnabled,
'is_onlyoffice_enabled' => $configurationManager->isOnlyofficeEnabled(),
'is_collabora_enabled' => $configurationManager->isCollaboraEnabled(),
'is_talk_enabled' => $configurationManager->isTalkEnabled(),

View file

@ -56,7 +56,7 @@ readonly class ContainerDefinitionFetcher {
$containers = [];
foreach ($data['aio_services_v1'] as $entry) {
if ($entry['container_name'] === 'nextcloud-aio-clamav') {
if (!$this->configurationManager->isClamavEnabled()) {
if (!$this->configurationManager->isClamavEnabled) {
continue;
}
} elseif ($entry['container_name'] === 'nextcloud-aio-onlyoffice') {
@ -168,7 +168,7 @@ readonly class ContainerDefinitionFetcher {
}
foreach ($valueDependsOn as $value) {
if ($value === 'nextcloud-aio-clamav') {
if (!$this->configurationManager->isClamavEnabled()) {
if (!$this->configurationManager->isClamavEnabled) {
continue;
}
} elseif ($value === 'nextcloud-aio-onlyoffice') {

View file

@ -88,11 +88,7 @@ readonly class ConfigurationController {
$this->configurationManager->SetCollaboraEnabledState(0);
$this->configurationManager->SetOnlyofficeEnabledState(0);
}
if (isset($request->getParsedBody()['clamav'])) {
$this->configurationManager->SetClamavEnabledState(1);
} else {
$this->configurationManager->SetClamavEnabledState(0);
$this->configurationManager->isClamavEnabled = isset($request->getParsedBody()['clamav']);
}
if (isset($request->getParsedBody()['talk'])) {
$this->configurationManager->SetTalkEnabledState(1);

View file

@ -68,6 +68,11 @@ class ConfigurationManager
set { $this->set('install_latest_major', $value); }
}
public bool $isClamavEnabled {
get => $this->get('isClamavEnabled', false);
set { $this->set('isClamavEnabled', $value); }
}
public function GetConfig() : array
{
if ($this->config === [] && file_exists(DataConst::GetConfigFile()))
@ -203,21 +208,6 @@ class ConfigurationManager
}
}
public function isClamavEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isClamavEnabled']) && $config['isClamavEnabled'] === 1) {
return true;
} else {
return false;
}
}
public function SetClamavEnabledState(int $value) : void {
$config = $this->GetConfig();
$config['isClamavEnabled'] = $value;
$this->WriteConfig($config);
}
public function isImaginaryEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isImaginaryEnabled']) && $config['isImaginaryEnabled'] === 0) {

View file

@ -571,7 +571,7 @@ readonly class DockerActionManager {
'TURN_DOMAIN' => $this->configurationManager->GetTurnDomain(),
'NEXTCLOUD_MOUNT' => $this->configurationManager->GetNextcloudMount(),
'BACKUP_RESTORE_PASSWORD' => $this->configurationManager->GetBorgRestorePassword(),
'CLAMAV_ENABLED' => $this->configurationManager->isClamavEnabled() ? 'yes' : '',
'CLAMAV_ENABLED' => $this->configurationManager->isClamavEnabled ? 'yes' : '',
'TALK_RECORDING_ENABLED' => $this->configurationManager->isTalkRecordingEnabled() ? 'yes' : '',
'ONLYOFFICE_ENABLED' => $this->configurationManager->isOnlyofficeEnabled() ? 'yes' : '',
'COLLABORA_ENABLED' => $this->configurationManager->isCollaboraEnabled() ? 'yes' : '',