2017-05-24 03:07:58 -04:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2026-02-09 04:53:58 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2017-05-24 03:07:58 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2017-05-24 03:07:58 -04:00
|
|
|
*/
|
|
|
|
|
namespace OC\GlobalScale;
|
|
|
|
|
|
|
|
|
|
use OCP\IConfig;
|
2025-11-20 12:02:21 -05:00
|
|
|
use Override;
|
2017-05-24 03:07:58 -04:00
|
|
|
|
|
|
|
|
class Config implements \OCP\GlobalScale\IConfig {
|
2025-11-17 09:32:54 -05:00
|
|
|
public function __construct(
|
2025-11-20 12:02:21 -05:00
|
|
|
private readonly IConfig $config,
|
2025-11-17 09:32:54 -05:00
|
|
|
) {
|
2017-05-24 03:07:58 -04:00
|
|
|
}
|
|
|
|
|
|
2025-11-20 12:02:21 -05:00
|
|
|
#[Override]
|
|
|
|
|
public function isGlobalScaleEnabled(): bool {
|
2023-04-05 06:50:08 -04:00
|
|
|
return $this->config->getSystemValueBool('gs.enabled', false);
|
2017-05-24 03:07:58 -04:00
|
|
|
}
|
|
|
|
|
|
2025-11-20 12:02:21 -05:00
|
|
|
#[Override]
|
|
|
|
|
public function onlyInternalFederation(): bool {
|
2017-05-24 03:07:58 -04:00
|
|
|
// if global scale is disabled federation works always globally
|
|
|
|
|
$gsEnabled = $this->isGlobalScaleEnabled();
|
|
|
|
|
if ($gsEnabled === false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-05 06:50:08 -04:00
|
|
|
$enabled = $this->config->getSystemValueString('gs.federation', 'internal');
|
2017-05-24 03:07:58 -04:00
|
|
|
|
|
|
|
|
return $enabled === 'internal';
|
|
|
|
|
}
|
|
|
|
|
}
|