Procházet zdrojové kódy

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>
tags/v14.0.0beta1
Joas Schilling před 6 roky
rodič
revize
b30e035e25
Žádný účet není propojen s e-mailovou adresou tvůrce revize

+ 2
- 0
lib/private/Collaboration/Collaborators/MailPlugin.php Zobrazit soubor

@@ -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)) {

+ 2
- 0
lib/private/Collaboration/Collaborators/RemotePlugin.php Zobrazit soubor

@@ -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) {

+ 2
- 2
tests/lib/Collaboration/Collaborators/MailPluginTest.php Zobrazit soubor

@@ -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')));

+ 1
- 1
tests/lib/Collaboration/Collaborators/RemotePluginTest.php Zobrazit soubor

@@ -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')));

Načítá se…
Zrušit
Uložit