diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2022-10-05 10:36:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-05 10:36:43 +0200 |
commit | 7d024bc337d9c9b43b80ed856c76c30e3f8edf97 (patch) | |
tree | 43b9f84194c0234fe5c1172c2ba01e0399ee8296 | |
parent | a178d6982d1e91ad10e066176da5b47f92c2fb90 (diff) | |
parent | ae6a7c88a004843e0dc976a4a616ffaceea4ee1a (diff) | |
download | nextcloud-server-7d024bc337d9c9b43b80ed856c76c30e3f8edf97.tar.gz nextcloud-server-7d024bc337d9c9b43b80ed856c76c30e3f8edf97.zip |
Merge pull request #32635 from andyxheli/patch-3
Fix User profile picture when performing the search
-rw-r--r-- | lib/private/Contacts/ContactsMenu/ContactsStore.php | 7 | ||||
-rw-r--r-- | tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index dd4bd973fa9..a0a14cd9cbd 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -284,8 +284,11 @@ class ContactsStore implements IContactsStore { private function contactArrayToEntry(array $contact): Entry { $entry = new Entry(); - if (isset($contact['id'])) { - $entry->setId($contact['id']); + if (isset($contact['UID'])) { + $uid = $contact['UID']; + $entry->setId($uid); + $avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]); + $entry->setAvatar($avatar); } if (isset($contact['FN'])) { diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php index aa609aedbb9..dfdd67fbb23 100644 --- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php +++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php @@ -140,6 +140,10 @@ class ContactsStoreTest extends TestCase { public function testGetContactsWithoutBinaryImage() { /** @var IUser|MockObject $user */ $user = $this->createMock(IUser::class); + $this->urlGenerator->expects($this->any()) + ->method('linkToRouteAbsolute') + ->with('core.avatar.getAvatar', $this->anything()) + ->willReturn('https://urlToNcAvatar.test'); $this->contactsManager->expects($this->once()) ->method('search') ->with($this->equalTo(''), $this->equalTo(['FN', 'EMAIL'])) @@ -163,7 +167,7 @@ class ContactsStoreTest extends TestCase { $entries = $this->contactsStore->getContacts($user, ''); $this->assertCount(2, $entries); - $this->assertNull($entries[1]->getAvatar()); + $this->assertSame('https://urlToNcAvatar.test', $entries[1]->getAvatar()); } public function testGetContactsWithoutAvatarURI() { |