Filter out the current user when searching for emails too

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2018-02-13 17:32:58 +01:00
parent 242f0c0b5a
commit 18968e84fc
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 9 additions and 2 deletions

View File

@ -28,9 +28,11 @@ use OCP\Collaboration\Collaborators\ISearchPlugin;
use OCP\Collaboration\Collaborators\ISearchResult;
use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\Contacts\IManager;
use OCP\Federation\ICloudId;
use OCP\Federation\ICloudIdManager;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Share;
@ -112,7 +114,7 @@ class MailPlugin implements ISearchPlugin {
continue;
}
if (!$searchResult->hasResult($userType, $cloud->getUser())) {
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
$singleResult = [[
'label' => $contact['FN'] . " ($emailAddress)",
'value' => [
@ -133,7 +135,7 @@ class MailPlugin implements ISearchPlugin {
continue;
}
if (!$searchResult->hasResult($userType, $cloud->getUser())) {
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
$singleResult = [[
'label' => $contact['FN'] . " ($emailAddress)",
'value' => [
@ -191,4 +193,9 @@ class MailPlugin implements ISearchPlugin {
return true;
}
public function isCurrentUser(ICloudId $cloud): bool {
$currentUser = $this->userSession->getUser();
return $currentUser instanceof IUser ? $currentUser->getUID() === $cloud->getUser() : false;
}
}