Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2022-10-05 11:36:43 +0300
committerGitHub <noreply@github.com>2022-10-05 11:36:43 +0300
commit7d024bc337d9c9b43b80ed856c76c30e3f8edf97 (patch)
tree43b9f84194c0234fe5c1172c2ba01e0399ee8296
parenta178d6982d1e91ad10e066176da5b47f92c2fb90 (diff)
parentae6a7c88a004843e0dc976a4a616ffaceea4ee1a (diff)
Merge pull request #32635 from andyxheli/patch-3
Fix User profile picture when performing the search
-rw-r--r--lib/private/Contacts/ContactsMenu/ContactsStore.php7
-rw-r--r--tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php6
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() {