Skip to content

Commit 7d024bc

Browse files
authored
Merge pull request #32635 from andyxheli/patch-3
Fix User profile picture when performing the search
2 parents a178d69 + ae6a7c8 commit 7d024bc

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/private/Contacts/ContactsMenu/ContactsStore.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,11 @@ public function findOne(IUser $user, int $shareType, string $shareWith): ?IEntry
284284
private function contactArrayToEntry(array $contact): Entry {
285285
$entry = new Entry();
286286

287-
if (isset($contact['id'])) {
288-
$entry->setId($contact['id']);
287+
if (isset($contact['UID'])) {
288+
$uid = $contact['UID'];
289+
$entry->setId($uid);
290+
$avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]);
291+
$entry->setAvatar($avatar);
289292
}
290293

291294
if (isset($contact['FN'])) {

tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ public function testGetContactsHidesOwnEntry() {
140140
public function testGetContactsWithoutBinaryImage() {
141141
/** @var IUser|MockObject $user */
142142
$user = $this->createMock(IUser::class);
143+
$this->urlGenerator->expects($this->any())
144+
->method('linkToRouteAbsolute')
145+
->with('core.avatar.getAvatar', $this->anything())
146+
->willReturn('https://urlToNcAvatar.test');
143147
$this->contactsManager->expects($this->once())
144148
->method('search')
145149
->with($this->equalTo(''), $this->equalTo(['FN', 'EMAIL']))
@@ -163,7 +167,7 @@ public function testGetContactsWithoutBinaryImage() {
163167
$entries = $this->contactsStore->getContacts($user, '');
164168

165169
$this->assertCount(2, $entries);
166-
$this->assertNull($entries[1]->getAvatar());
170+
$this->assertSame('https://urlToNcAvatar.test', $entries[1]->getAvatar());
167171
}
168172

169173
public function testGetContactsWithoutAvatarURI() {

0 commit comments

Comments
 (0)