Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/private/Collaboration/Collaborators/MailPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdM
* @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');

Expand Down Expand Up @@ -136,14 +136,13 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
}

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;
Expand Down Expand Up @@ -175,10 +174,13 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {

if (!$this->shareeEnumeration) {
$result['wide'] = [];
$userResults['wide'] = [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: also enumeration was possible before, pretty bad...

} 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,
Expand All @@ -189,6 +191,9 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
];
}

if (!empty($userResults['wide'])) {
$searchResult->addResultSet($userType, $userResults['wide'], []);
}
$searchResult->addResultSet($emailType, $result['wide'], $result['exact']);

return true;
Expand Down