Skip to content

Commit

Permalink
fix(lookup-server): do not query data by default
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Mar 10, 2025
1 parent 778cf5e commit 9dba843
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
3 changes: 1 addition & 2 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,7 @@ 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');
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,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 Down
9 changes: 3 additions & 6 deletions apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,9 @@ public function search(string $search = '', ?string $itemType = null, int $page
$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';
}
$lookup = $this->config->getSystemValueBool('gs.enabled', false)
|| $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no') === 'yes';
$this->result['lookupEnabled'] = $lookup;

[$result, $hasMoreResults] = $this->collaboratorSearch->search($search, $shareTypes, $lookup, $this->limit, $this->offset);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function testSearch(
->method('getAppValue')
->with($this->anything(), $this->anything(), $this->anything())
->willReturnMap([
['files_sharing', 'lookupServerEnabled', 'yes', 'yes'],
['files_sharing', 'lookupServerEnabled', 'no', 'yes'],
]);

$this->shareManager->expects($this->once())
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Collaboration/Collaborators/LookupPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(

public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
$isGlobalScaleEnabled = $this->config->getSystemValueBool('gs.enabled', false);
$isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
$isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no') === 'yes';
$hasInternetConnection = $this->config->getSystemValueBool('has_internet_connection', true);

// if case of Global Scale we always search the lookup server
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/Collaboration/Collaborators/LookupPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function setUp(): void {
public function testSearchNoLookupServerURI(): void {
$this->config->expects($this->once())
->method('getAppValue')
->with('files_sharing', 'lookupServerEnabled', 'yes')
->with('files_sharing', 'lookupServerEnabled', 'no')
->willReturn('yes');
$this->config->expects($this->exactly(2))
->method('getSystemValueBool')
Expand Down Expand Up @@ -101,7 +101,7 @@ public function testSearchNoLookupServerURI(): void {
public function testSearchNoInternet(): void {
$this->config->expects($this->once())
->method('getAppValue')
->with('files_sharing', 'lookupServerEnabled', 'yes')
->with('files_sharing', 'lookupServerEnabled', 'no')
->willReturn('yes');
$this->config->expects($this->exactly(2))
->method('getSystemValueBool')
Expand Down Expand Up @@ -137,7 +137,7 @@ public function testSearch(array $searchParams): void {

$this->config->expects($this->once())
->method('getAppValue')
->with('files_sharing', 'lookupServerEnabled', 'yes')
->with('files_sharing', 'lookupServerEnabled', 'no')
->willReturn('yes');
$this->config->expects($this->exactly(2))
->method('getSystemValueBool')
Expand Down Expand Up @@ -197,7 +197,7 @@ public function testSearchEnableDisableLookupServer(array $searchParams, $GSEnab

$this->config->expects($this->once())
->method('getAppValue')
->with('files_sharing', 'lookupServerEnabled', 'yes')
->with('files_sharing', 'lookupServerEnabled', 'no')
->willReturn($LookupEnabled ? 'yes' : 'no');
if ($GSEnabled || $LookupEnabled) {
$searchResult->expects($this->once())
Expand Down

0 comments on commit 9dba843

Please sign in to comment.