From c19c05999422eb380f1eb4401f394d138156211d Mon Sep 17 00:00:00 2001 From: Andy Xheli Date: Fri, 27 May 2022 14:48:06 -0500 Subject: [PATCH 1/5] Fix User profile picture when performing the search Signed-off-by: Andy Xheli Before ![image](https://user-images.githubusercontent.com/59488153/140980158-b9108161-57ab-48b4-ae6f-98ec4e72775a.png) After Fix for #31065 --- lib/private/Contacts/ContactsMenu/ContactsStore.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index 020e8604910..2edb04df926 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'])) { + $entry->setId($contact['UID']); + $uid = $contact['UID']; + $avatar = "/index.php/avatar/$uid/64"; + $entry->setAvatar($avatar); } if (isset($contact['FN'])) { From c2c2e3ce52c1689bcf5d99c3b945a4715f952b95 Mon Sep 17 00:00:00 2001 From: Andy Xheli Date: Fri, 16 Sep 2022 11:29:09 -0500 Subject: [PATCH 2/5] Apply suggestions from code review Signed-off-by: Andy Xheli Co-authored-by: Carl Schwan Signed-off-by: Andy Xheli --- lib/private/Contacts/ContactsMenu/ContactsStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index 2edb04df926..aac213f6aa4 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -287,7 +287,7 @@ class ContactsStore implements IContactsStore { if (isset($contact['UID'])) { $entry->setId($contact['UID']); $uid = $contact['UID']; - $avatar = "/index.php/avatar/$uid/64"; + $avatar = $this->urlGenerator->linkToRoute('core.getAvatar', ['userId' => $uid, 'size' => 64]); $entry->setAvatar($avatar); } From e661d3cc99d4d3b7810da0b2636286725d13efb1 Mon Sep 17 00:00:00 2001 From: Andy Xheli Date: Mon, 19 Sep 2022 09:06:12 -0500 Subject: [PATCH 3/5] Update ContactsStore.php Signed-off-by: Andy Xheli --- lib/private/Contacts/ContactsMenu/ContactsStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index aac213f6aa4..112a708f980 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -287,7 +287,7 @@ class ContactsStore implements IContactsStore { if (isset($contact['UID'])) { $entry->setId($contact['UID']); $uid = $contact['UID']; - $avatar = $this->urlGenerator->linkToRoute('core.getAvatar', ['userId' => $uid, 'size' => 64]); + $avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]); $entry->setAvatar($avatar); } From 2cff329188fc1e0a5c42a8ef3958a337d38d7981 Mon Sep 17 00:00:00 2001 From: Andy Xheli Date: Tue, 20 Sep 2022 12:05:29 -0500 Subject: [PATCH 4/5] Update lib/private/Contacts/ContactsMenu/ContactsStore.php Signed-off-by: Andy Xheli Tested no issues. Co-authored-by: Pytal <24800714+Pytal@users.noreply.github.com> Signed-off-by: Andy Xheli --- lib/private/Contacts/ContactsMenu/ContactsStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index 112a708f980..002e9940869 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -285,8 +285,8 @@ class ContactsStore implements IContactsStore { $entry = new Entry(); if (isset($contact['UID'])) { - $entry->setId($contact['UID']); $uid = $contact['UID']; + $entry->setId($uid); $avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]); $entry->setAvatar($avatar); } From ae6a7c88a004843e0dc976a4a616ffaceea4ee1a Mon Sep 17 00:00:00 2001 From: Andy Xheli Date: Mon, 3 Oct 2022 09:17:27 -0500 Subject: [PATCH 5/5] Update ContactsStoreTest.php Signed-off-by: Andy Xheli --- tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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() {