Better result handling of email search

1. Local users should not be returned when searching for empty string
2. The limit of the response should be respected

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2018-02-06 18:11:44 +01:00
parent a3de507b76
commit d63caf5829
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
4 changed files with 7 additions and 3 deletions

View File

@ -173,6 +173,8 @@ class MailPlugin implements ISearchPlugin {
if (!$this->shareeEnumeration) {
$result['wide'] = [];
} else {
$result['wide'] = array_slice($result['wide'], $offset, $limit);
}
if (!$searchResult->hasExactIdMatch($emailType) && filter_var($search, FILTER_VALIDATE_EMAIL)) {

View File

@ -102,6 +102,8 @@ class RemotePlugin implements ISearchPlugin {
if (!$this->shareeEnumeration) {
$result['wide'] = [];
} else {
$result['wide'] = array_slice($result['wide'], $offset, $limit);
}
if (!$searchResult->hasExactIdMatch($resultType) && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) {

View File

@ -103,7 +103,7 @@ class MailPluginTest extends TestCase {
->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')));
@ -398,7 +398,7 @@ class MailPluginTest extends TestCase {
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')));

View File

@ -94,7 +94,7 @@ class RemotePluginTest extends TestCase {
->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')));