Also array_slice wide email matches of local users

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2018-03-01 12:18:44 +01:00
parent d1547ee3b0
commit 5b6590f1e9
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 7 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,
@ -190,6 +192,7 @@ class MailPlugin implements ISearchPlugin {
}
$searchResult->addResultSet($emailType, $result['wide'], $result['exact']);
$searchResult->addResultSet($userType, [], $userResults['wide']);
return true;
}