diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-03-11 21:17:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-11 21:17:11 +0100 |
commit | 38e8f30fb763771414a80cafa9d29e12599cf4b3 (patch) | |
tree | ccdb14ca1d62f86c157f72aa3b3e636befaad26f /apps | |
parent | bbd3a3cd87e4134cd3211d77c7ccd357f6c28095 (diff) | |
parent | 86767fb99d92dafbbb5041016849a28acf91d2fe (diff) | |
download | nextcloud-server-38e8f30fb763771414a80cafa9d29e12599cf4b3.tar.gz nextcloud-server-38e8f30fb763771414a80cafa9d29e12599cf4b3.zip |
Merge pull request #51378 from nextcloud/fix/lookup-server-connector-v2
fix(lookup-server): disable when not using global scale
Diffstat (limited to 'apps')
8 files changed, 64 insertions, 45 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index c7ee40a0cbe..58eaca0361e 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -998,8 +998,10 @@ class FederatedShareProvider implements IShareProvider { if ($this->gsConfig->isGlobalScaleEnabled()) { return true; } - $result = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes'); - return $result === 'yes'; + $result = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no') === 'yes'; + // TODO: Reenable if lookup server is used again + // return $result; + return false; } @@ -1011,8 +1013,10 @@ class FederatedShareProvider implements IShareProvider { if ($this->gsConfig->isGlobalScaleEnabled()) { return false; } - $result = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes'); - return $result === 'yes'; + $result = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'no') === 'yes'; + // TODO: Reenable if lookup server is used again + // return $result; + return false; } /** diff --git a/apps/federatedfilesharing/src/components/AdminSettings.vue b/apps/federatedfilesharing/src/components/AdminSettings.vue index 50ca46ae2b4..9f565aea3f6 100644 --- a/apps/federatedfilesharing/src/components/AdminSettings.vue +++ b/apps/federatedfilesharing/src/components/AdminSettings.vue @@ -32,17 +32,23 @@ {{ t('federatedfilesharing', 'Allow people on this server to receive group shares from other servers') }} </NcCheckboxRadioSwitch> - <NcCheckboxRadioSwitch type="switch" - :checked.sync="lookupServerEnabled" - @update:checked="update('lookupServerEnabled', lookupServerEnabled)"> - {{ t('federatedfilesharing', 'Search global and public address book for people') }} - </NcCheckboxRadioSwitch> + <fieldset> + <legend>{{ t('federatedfilesharing', 'The lookup server is only available for global scale.') }}</legend> - <NcCheckboxRadioSwitch type="switch" - :checked.sync="lookupServerUploadEnabled" - @update:checked="update('lookupServerUploadEnabled', lookupServerUploadEnabled)"> - {{ t('federatedfilesharing', 'Allow people to publish their data to a global and public address book') }} - </NcCheckboxRadioSwitch> + <NcCheckboxRadioSwitch type="switch" + :checked.sync="lookupServerEnabled" + disabled + @update:checked="update('lookupServerEnabled', lookupServerEnabled)"> + {{ t('federatedfilesharing', 'Search global and public address book for people') }} + </NcCheckboxRadioSwitch> + + <NcCheckboxRadioSwitch type="switch" + :checked.sync="lookupServerUploadEnabled" + disabled + @update:checked="update('lookupServerUploadEnabled', lookupServerUploadEnabled)"> + {{ t('federatedfilesharing', 'Allow people to publish their data to a global and public address book') }} + </NcCheckboxRadioSwitch> + </fieldset> <!-- Trusted server handling --> <div class="settings-subsection"> diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 2bdc2d5e744..002a8bac374 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -825,7 +825,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->gsConfig->expects($this->once())->method('isGlobalScaleEnabled') ->willReturn($gsEnabled); $this->config->expects($this->any())->method('getAppValue') - ->with('files_sharing', 'lookupServerEnabled', 'yes') + ->with('files_sharing', 'lookupServerEnabled', 'no') ->willReturn($isEnabled); $this->assertSame($expected, @@ -836,10 +836,13 @@ class FederatedShareProviderTest extends \Test\TestCase { public function dataTestIsLookupServerQueriesEnabled() { return [ - [false, 'yes', true], - [false, 'no', false], [true, 'yes', true], [true, 'no', true], + // TODO: reenable if we use the lookup server for non-global scale + // [false, 'yes', true], + // [false, 'no', false], + [false, 'no', false], + [false, 'yes', false], ]; } @@ -853,7 +856,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->gsConfig->expects($this->once())->method('isGlobalScaleEnabled') ->willReturn($gsEnabled); $this->config->expects($this->any())->method('getAppValue') - ->with('files_sharing', 'lookupServerUploadEnabled', 'yes') + ->with('files_sharing', 'lookupServerUploadEnabled', 'no') ->willReturn($isEnabled); $this->assertSame($expected, @@ -863,10 +866,13 @@ class FederatedShareProviderTest extends \Test\TestCase { public function dataTestIsLookupServerUploadEnabled() { return [ - [false, 'yes', true], - [false, 'no', false], [true, 'yes', false], [true, 'no', false], + // TODO: reenable if we use the lookup server again + // [false, 'yes', true], + // [false, 'no', false], + [false, 'yes', false], + [false, 'no', false], ]; } diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index d61dd7faf30..0c458ce9662 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -22,6 +22,7 @@ use OCP\Collaboration\Collaborators\ISearch; use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\Constants; +use OCP\GlobalScale\IConfig as GlobalScaleIConfig; use OCP\IConfig; use OCP\IRequest; use OCP\IURLGenerator; @@ -175,15 +176,11 @@ class ShareesAPIController extends OCSController { $this->limit = $perPage; $this->offset = $perPage * ($page - 1); - // In global scale mode we always search the loogup server - if ($this->config->getSystemValueBool('gs.enabled', false)) { - $lookup = true; - $this->result['lookupEnabled'] = true; - } else { - $this->result['lookupEnabled'] = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes'; - } + // In global scale mode we always search the lookup server + $this->result['lookupEnabled'] = Server::get(GlobalScaleIConfig::class)->isGlobalScaleEnabled(); + // TODO: Reconsider using lookup server for non-global-scale federation - [$result, $hasMoreResults] = $this->collaboratorSearch->search($search, $shareTypes, $lookup, $this->limit, $this->offset); + [$result, $hasMoreResults] = $this->collaboratorSearch->search($search, $shareTypes, $this->result['lookupEnabled'], $this->limit, $this->offset); // extra treatment for 'exact' subarray, with a single merge expected keys might be lost if (isset($result['exact'])) { diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php index b3b395da8c0..c8113558f6c 100644 --- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php @@ -11,6 +11,7 @@ use OCA\Files_Sharing\Tests\TestCase; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\Collaboration\Collaborators\ISearch; +use OCP\GlobalScale\IConfig as GlobalScaleIConfig; use OCP\IConfig; use OCP\IRequest; use OCP\IURLGenerator; @@ -229,14 +230,14 @@ class ShareesAPIControllerTest extends TestCase { $perPage = $getData['perPage'] ?? 200; $shareType = $getData['shareType'] ?? null; + $globalConfig = $this->createMock(GlobalScaleIConfig::class); + $globalConfig->expects(self::once()) + ->method('isGlobalScaleEnabled') + ->willReturn(true); + $this->overwriteService(GlobalScaleIConfig::class, $globalConfig); + /** @var IConfig|MockObject $config */ $config = $this->createMock(IConfig::class); - $config->expects($this->exactly(1)) - ->method('getAppValue') - ->with($this->anything(), $this->anything(), $this->anything()) - ->willReturnMap([ - ['files_sharing', 'lookupServerEnabled', 'yes', 'yes'], - ]); $this->shareManager->expects($this->once()) ->method('allowGroupSharing') diff --git a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php index 924dec6762d..08fe0b3fa2b 100644 --- a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php +++ b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php @@ -84,10 +84,12 @@ class RetryJob extends Job { * - max retries are reached (set to 5) */ protected function shouldRemoveBackgroundJob(): bool { - return $this->config->getSystemValueBool('has_internet_connection', true) === false || - $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') === '' || - $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') !== 'yes' || - $this->retries >= 5; + // TODO: Remove global scale condition once lookup server is used for non-global scale federation + // return $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'no') !== 'yes' + return !$this->config->getSystemValueBool('gs.enabled', false) + || $this->config->getSystemValueBool('has_internet_connection', true) === false + || $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') === '' + || $this->retries >= 5; } protected function shouldRun(): bool { @@ -149,7 +151,7 @@ class RetryJob extends Job { $user->getUID(), 'lookup_server_connector', 'update_retries', - $this->retries + 1 + (string)($this->retries + 1), ); } } diff --git a/apps/lookup_server_connector/lib/UpdateLookupServer.php b/apps/lookup_server_connector/lib/UpdateLookupServer.php index c689cea1fe0..dac3e8a80fa 100644 --- a/apps/lookup_server_connector/lib/UpdateLookupServer.php +++ b/apps/lookup_server_connector/lib/UpdateLookupServer.php @@ -56,8 +56,9 @@ class UpdateLookupServer { * @return bool */ private function shouldUpdateLookupServer(): bool { - return $this->config->getSystemValueBool('has_internet_connection', true) === true && - $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') === 'yes' && - $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') !== ''; + // TODO: Consider reenable for non-global-scale setups by checking "'files_sharing', 'lookupServerUploadEnabled'" instead of "gs.enabled" + return $this->config->getSystemValueBool('gs.enabled', false) + && $this->config->getSystemValueBool('has_internet_connection', true) + && $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com') !== ''; } } diff --git a/apps/settings/lib/BackgroundJobs/VerifyUserData.php b/apps/settings/lib/BackgroundJobs/VerifyUserData.php index 62b7c44c8ef..eb66644ad91 100644 --- a/apps/settings/lib/BackgroundJobs/VerifyUserData.php +++ b/apps/settings/lib/BackgroundJobs/VerifyUserData.php @@ -120,9 +120,11 @@ class VerifyUserData extends Job { } protected function verifyViaLookupServer(array $argument, string $dataType): bool { - if (empty($this->lookupServerUrl) || - $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') !== 'yes' || - $this->config->getSystemValue('has_internet_connection', true) === false) { + // TODO: Consider to enable for non-global-scale setups by checking 'files_sharing', 'lookupServerUploadEnabled' + if (!$this->config->getSystemValueBool('gs.enabled', false) + || empty($this->lookupServerUrl) + || $this->config->getSystemValue('has_internet_connection', true) === false + ) { return true; } |