From cf216ecff2e09f713d5b37206d61ea7476ea1f37 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 13 Feb 2018 17:32:58 +0100 Subject: Filter out the current user when searching for emails too Signed-off-by: Joas Schilling --- lib/private/Collaboration/Collaborators/MailPlugin.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index 2e946c4a872..2d85ff334bc 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -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' => [ @@ -189,4 +191,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; + } } -- cgit v1.2.3