mirror of
https://github.com/nextcloud/server.git
synced 2026-04-28 09:37:29 -04:00
Do not remove current user on findOne
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
parent
873e8e219c
commit
5e23800a95
2 changed files with 27 additions and 28 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class ContactsStoreTest extends TestCase {
|
|||
],
|
||||
],
|
||||
]);
|
||||
$user->expects($this->once())
|
||||
$user->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user123');
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ class ContactsStoreTest extends TestCase {
|
|||
],
|
||||
],
|
||||
]);
|
||||
$user->expects($this->once())
|
||||
$user->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user123');
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ class ContactsStoreTest extends TestCase {
|
|||
'PHOTO' => base64_encode('photophotophoto'),
|
||||
],
|
||||
]);
|
||||
$user->expects($this->once())
|
||||
$user->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user123');
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ class ContactsStoreTest extends TestCase {
|
|||
'PHOTO' => 'VALUE=uri:https://photo',
|
||||
],
|
||||
]);
|
||||
$user->expects($this->once())
|
||||
$user->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user123');
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ class ContactsStoreTest extends TestCase {
|
|||
|
||||
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
|
||||
$currentUser = $this->createMock(IUser::class);
|
||||
$currentUser->expects($this->once())
|
||||
$currentUser->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user001');
|
||||
|
||||
|
|
@ -253,7 +253,7 @@ class ContactsStoreTest extends TestCase {
|
|||
|
||||
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
|
||||
$currentUser = $this->createMock(IUser::class);
|
||||
$currentUser->expects($this->once())
|
||||
$currentUser->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user001');
|
||||
|
||||
|
|
@ -332,7 +332,7 @@ class ContactsStoreTest extends TestCase {
|
|||
|
||||
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
|
||||
$currentUser = $this->createMock(IUser::class);
|
||||
$currentUser->expects($this->once())
|
||||
$currentUser->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user001');
|
||||
|
||||
|
|
@ -411,7 +411,7 @@ class ContactsStoreTest extends TestCase {
|
|||
|
||||
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
|
||||
$currentUser = $this->createMock(IUser::class);
|
||||
$currentUser->expects($this->once())
|
||||
$currentUser->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user001');
|
||||
|
||||
|
|
@ -469,7 +469,7 @@ class ContactsStoreTest extends TestCase {
|
|||
|
||||
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
|
||||
$currentUser = $this->createMock(IUser::class);
|
||||
$currentUser->expects($this->once())
|
||||
$currentUser->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user001');
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ class ContactsStoreTest extends TestCase {
|
|||
|
||||
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
|
||||
$currentUser = $this->createMock(IUser::class);
|
||||
$currentUser->expects($this->once())
|
||||
$currentUser->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user001');
|
||||
|
||||
|
|
@ -624,7 +624,7 @@ class ContactsStoreTest extends TestCase {
|
|||
|
||||
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $currentUser */
|
||||
$currentUser = $this->createMock(IUser::class);
|
||||
$currentUser->expects($this->once())
|
||||
$currentUser->expects($this->exactly(2))
|
||||
->method('getUID')
|
||||
->willReturn('user001');
|
||||
|
||||
|
|
@ -963,9 +963,8 @@ class ContactsStoreTest extends TestCase {
|
|||
'isLocalSystemBook' => false
|
||||
],
|
||||
]);
|
||||
$user->expects($this->once())
|
||||
->method('getUID')
|
||||
->willReturn('user123');
|
||||
$user->expects($this->never())
|
||||
->method('getUID');
|
||||
|
||||
$entry = $this->contactsStore->findOne($user, 0, 'a567');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue