diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2021-10-20 10:47:23 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2021-10-20 11:53:45 +0200 |
commit | 5e23800a95290f5e4ca4d5eac8fa222b1ca34a34 (patch) | |
tree | 0d9e5f1b33f48e3bad48be370d6ba7b8f36fac55 /lib/private/Contacts | |
parent | 873e8e219cb7d9c0651260a3b4f138618a22f31e (diff) | |
download | nextcloud-server-5e23800a95290f5e4ca4d5eac8fa222b1ca34a34.tar.gz nextcloud-server-5e23800a95290f5e4ca4d5eac8fa222b1ca34a34.zip |
Do not remove current user on findOne
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/private/Contacts')
-rw-r--r-- | lib/private/Contacts/ContactsMenu/ContactsStore.php | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index a4a53bf8774..eb7e752a87a 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -113,9 +113,18 @@ class ContactsStore implements IContactsStore { $options ); + $userId = $user->getUID(); + $contacts = array_filter($allContacts, function ($contact) use ($userId) { + // When searching for multiple results, we strip out the current user + if (array_key_exists('UID', $contact)) { + return $contact['UID'] !== $userId; + } + return true; + }); + $entries = array_map(function (array $contact) { return $this->contactArrayToEntry($contact); - }, $allContacts); + }, $contacts); return $this->filterContacts( $user, $entries, @@ -125,12 +134,11 @@ class ContactsStore implements IContactsStore { /** * Filters the contacts. Applied filters: - * 1. filter the current user - * 2. if the `shareapi_allow_share_dialog_user_enumeration` config option is + * 1. if the `shareapi_allow_share_dialog_user_enumeration` config option is * enabled it will filter all local users - * 3. if the `shareapi_exclude_groups` config option is enabled and the + * 2. if the `shareapi_exclude_groups` config option is enabled and the * current user is in an excluded group it will filter all local users. - * 4. if the `shareapi_only_share_with_group_members` config option is + * 3. if the `shareapi_only_share_with_group_members` config option is * enabled it will filter all users which doens't have a common group * with the current user. * @@ -171,10 +179,6 @@ class ContactsStore implements IContactsStore { $selfUID = $self->getUID(); return array_values(array_filter($entries, function (IEntry $entry) use ($skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $restrictEnumerationGroup, $restrictEnumerationPhone, $allowEnumerationFullMatch, $filter) { - if ($entry->getProperty('UID') === $selfUID) { - return false; - } - if ($entry->getProperty('isLocalSystemBook')) { if ($skipLocal) { return false; @@ -266,11 +270,7 @@ class ContactsStore implements IContactsStore { return null; } - $userId = $user->getUID(); - $allContacts = $this->contactsManager->search($shareWith, $filter); - $contacts = array_filter($allContacts, function ($contact) use ($userId) { - return $contact['UID'] !== $userId; - }); + $contacts = $this->contactsManager->search($shareWith, $filter); $match = null; foreach ($contacts as $contact) { |