Skip to content

Commit cf216ec

Browse files
committed
Filter out the current user when searching for emails too
Signed-off-by: Joas Schilling <[email protected]>
1 parent 91c67eb commit cf216ec

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/private/Collaboration/Collaborators/MailPlugin.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
use OCP\Collaboration\Collaborators\ISearchResult;
2929
use OCP\Collaboration\Collaborators\SearchResultType;
3030
use OCP\Contacts\IManager;
31+
use OCP\Federation\ICloudId;
3132
use OCP\Federation\ICloudIdManager;
3233
use OCP\IConfig;
3334
use OCP\IGroupManager;
35+
use OCP\IUser;
3436
use OCP\IUserSession;
3537
use OCP\Share;
3638

@@ -112,7 +114,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
112114
continue;
113115
}
114116

115-
if (!$searchResult->hasResult($userType, $cloud->getUser())) {
117+
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
116118
$singleResult = [[
117119
'label' => $contact['FN'] . " ($emailAddress)",
118120
'value' => [
@@ -133,7 +135,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
133135
continue;
134136
}
135137

136-
if (!$searchResult->hasResult($userType, $cloud->getUser())) {
138+
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
137139
$singleResult = [[
138140
'label' => $contact['FN'] . " ($emailAddress)",
139141
'value' => [
@@ -189,4 +191,9 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
189191

190192
return true;
191193
}
194+
195+
public function isCurrentUser(ICloudId $cloud): bool {
196+
$currentUser = $this->userSession->getUser();
197+
return $currentUser instanceof IUser ? $currentUser->getUID() === $cloud->getUser() : false;
198+
}
192199
}

0 commit comments

Comments
 (0)