Filter out the current user when searching for emails too
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
91c67eb667
commit
cf216ecff2
|
@ -28,9 +28,11 @@ use OCP\Collaboration\Collaborators\ISearchPlugin;
|
||||||
use OCP\Collaboration\Collaborators\ISearchResult;
|
use OCP\Collaboration\Collaborators\ISearchResult;
|
||||||
use OCP\Collaboration\Collaborators\SearchResultType;
|
use OCP\Collaboration\Collaborators\SearchResultType;
|
||||||
use OCP\Contacts\IManager;
|
use OCP\Contacts\IManager;
|
||||||
|
use OCP\Federation\ICloudId;
|
||||||
use OCP\Federation\ICloudIdManager;
|
use OCP\Federation\ICloudIdManager;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
|
use OCP\IUser;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\Share;
|
use OCP\Share;
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ class MailPlugin implements ISearchPlugin {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$searchResult->hasResult($userType, $cloud->getUser())) {
|
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
|
||||||
$singleResult = [[
|
$singleResult = [[
|
||||||
'label' => $contact['FN'] . " ($emailAddress)",
|
'label' => $contact['FN'] . " ($emailAddress)",
|
||||||
'value' => [
|
'value' => [
|
||||||
|
@ -133,7 +135,7 @@ class MailPlugin implements ISearchPlugin {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$searchResult->hasResult($userType, $cloud->getUser())) {
|
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
|
||||||
$singleResult = [[
|
$singleResult = [[
|
||||||
'label' => $contact['FN'] . " ($emailAddress)",
|
'label' => $contact['FN'] . " ($emailAddress)",
|
||||||
'value' => [
|
'value' => [
|
||||||
|
@ -189,4 +191,9 @@ class MailPlugin implements ISearchPlugin {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isCurrentUser(ICloudId $cloud): bool {
|
||||||
|
$currentUser = $this->userSession->getUser();
|
||||||
|
return $currentUser instanceof IUser ? $currentUser->getUID() === $cloud->getUser() : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue