Skip to content

Commit

Permalink
Merge pull request #8206 from nextcloud/bugfix/noid/fix-collaboration…
Browse files Browse the repository at this point in the history
…-result-size

Better result handling of email search
  • Loading branch information
blizzz authored Feb 20, 2018
2 parents cf83eb5 + b30e035 commit 8e5120c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/private/Collaboration/Collaborators/MailPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {

if (!$this->shareeEnumeration) {
$result['wide'] = [];
} else {
$result['wide'] = array_slice($result['wide'], $offset, $limit);
}

if (!$searchResult->hasExactIdMatch($emailType) && filter_var($search, FILTER_VALIDATE_EMAIL)) {
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Collaboration/Collaborators/RemotePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {

if (!$this->shareeEnumeration) {
$result['wide'] = [];
} else {
$result['wide'] = array_slice($result['wide'], $offset, $limit);
}

if (!$searchResult->hasExactIdMatch($resultType) && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) {
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Collaboration/Collaborators/MailPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function($appName, $key, $default)
->with($searchTerm, ['EMAIL', 'FN'])
->willReturn($contacts);

$moreResults = $this->plugin->search($searchTerm, 0, 0, $this->searchResult);
$moreResults = $this->plugin->search($searchTerm, 2, 0, $this->searchResult);
$result = $this->searchResult->asArray();

$this->assertSame($exactIdMatch, $this->searchResult->hasExactIdMatch(new SearchResultType('emails')));
Expand Down Expand Up @@ -398,7 +398,7 @@ function($appName, $key, $default) {
return in_array($group, $userToGroupMapping[$userId]);
});

$moreResults = $this->plugin->search($searchTerm, 0, 0, $this->searchResult);
$moreResults = $this->plugin->search($searchTerm, 2, 0, $this->searchResult);
$result = $this->searchResult->asArray();

$this->assertSame($exactIdMatch, $this->searchResult->hasExactIdMatch(new SearchResultType('emails')));
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Collaboration/Collaborators/RemotePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function($appName, $key, $default)
->with($searchTerm, ['CLOUD', 'FN'])
->willReturn($contacts);

$moreResults = $this->plugin->search($searchTerm, 0, 0, $this->searchResult);
$moreResults = $this->plugin->search($searchTerm, 2, 0, $this->searchResult);
$result = $this->searchResult->asArray();

$this->assertSame($exactIdMatch, $this->searchResult->hasExactIdMatch(new SearchResultType('remotes')));
Expand Down

0 comments on commit 8e5120c

Please sign in to comment.