Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,10 @@ public function isLookupServerQueriesEnabled(): bool {
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;
}


Expand All @@ -1011,8 +1013,10 @@ public function isLookupServerUploadEnabled(): bool {
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;
}

/**
Expand Down
26 changes: 16 additions & 10 deletions apps/federatedfilesharing/src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
18 changes: 12 additions & 6 deletions apps/federatedfilesharing/tests/FederatedShareProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ public function testIsLookupServerQueriesEnabled($gsEnabled, $isEnabled, $expect
$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,
Expand All @@ -835,10 +835,13 @@ public function testIsLookupServerQueriesEnabled($gsEnabled, $isEnabled, $expect

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],
];
}

Expand All @@ -852,7 +855,7 @@ public function testIsLookupServerUploadEnabled($gsEnabled, $isEnabled, $expecte
$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,
Expand All @@ -862,10 +865,13 @@ public function testIsLookupServerUploadEnabled($gsEnabled, $isEnabled, $expecte

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],
];
}

Expand Down
13 changes: 5 additions & 8 deletions apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;
Expand Down Expand Up @@ -173,15 +174,11 @@ public function search(string $search = '', ?string $itemType = null, int $page
$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'] = \OCP\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'])) {
Expand Down
13 changes: 7 additions & 6 deletions apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;
Expand Down Expand Up @@ -229,14 +230,14 @@ public function testSearch(
$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')
Expand Down
12 changes: 7 additions & 5 deletions apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ public function start(IJobList $jobList): void {
* - 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 {
Expand Down Expand Up @@ -149,7 +151,7 @@ protected function run($argument): void {
$user->getUID(),
'lookup_server_connector',
'update_retries',
$this->retries + 1
(string)($this->retries + 1),
);
}
}
Expand Down
7 changes: 4 additions & 3 deletions apps/lookup_server_connector/lib/UpdateLookupServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public function userUpdated(IUser $user): void {
* @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') !== '';
}
}
8 changes: 5 additions & 3 deletions apps/settings/lib/BackgroundJobs/VerifyUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ protected function verifyWebsite(array $argument) {
}

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;
}

Expand Down
5 changes: 0 additions & 5 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -988,11 +988,6 @@
<code><![CDATA[$storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')]]></code>
</RedundantCondition>
</file>
<file src="apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php">
<InvalidArgument>
<code><![CDATA[$this->retries + 1]]></code>
</InvalidArgument>
</file>
<file src="apps/oauth2/lib/Controller/OauthApiController.php">
<NoInterfaceProperties>
<code><![CDATA[$this->request->server]]></code>
Expand Down
Loading
Loading