Merge pull request #8596 from nextcloud/bugfix/8454/sharee-email-matches-not-limited

Also array_slice wide email matches of local users
This commit is contained in:
Morris Jobke 2018-03-06 22:21:03 +01:00 committed by GitHub
commit 65cc155a11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -73,7 +73,7 @@ class MailPlugin implements ISearchPlugin {
* @since 13.0.0
*/
public function search($search, $limit, $offset, ISearchResult $searchResult) {
$result = ['wide' => [], 'exact' => []];
$result = $userResults = ['wide' => [], 'exact' => []];
$userType = new SearchResultType('users');
$emailType = new SearchResultType('emails');
@ -136,14 +136,13 @@ class MailPlugin implements ISearchPlugin {
}
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
$singleResult = [[
$userResults['wide'][] = [
'label' => $contact['FN'] . " ($emailAddress)",
'value' => [
'shareType' => Share::SHARE_TYPE_USER,
'shareWith' => $cloud->getUser(),
]],
],
];
$searchResult->addResultSet($userType, $singleResult, []);
}
}
continue;
@ -175,10 +174,13 @@ class MailPlugin implements ISearchPlugin {
if (!$this->shareeEnumeration) {
$result['wide'] = [];
$userResults['wide'] = [];
} else {
$result['wide'] = array_slice($result['wide'], $offset, $limit);
$userResults['wide'] = array_slice($userResults['wide'], $offset, $limit);
}
if (!$searchResult->hasExactIdMatch($emailType) && filter_var($search, FILTER_VALIDATE_EMAIL)) {
$result['exact'][] = [
'label' => $search,
@ -189,6 +191,9 @@ class MailPlugin implements ISearchPlugin {
];
}
if (!empty($userResults['wide'])) {
$searchResult->addResultSet($userType, $userResults['wide'], []);
}
$searchResult->addResultSet($emailType, $result['wide'], $result['exact']);
return true;