From 511ade949735cfcc762e315e2c25b2c3c28ee8db 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 dd4bd973fa94c..2c84aa9dc9c3e 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -284,8 +284,11 @@ public function findOne(IUser $user, int $shareType, string $shareWith): ?IEntry 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 31e5e102c1b97bd285dc6930cd575e337741fc6d 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 2c84aa9dc9c3e..a9e0439f1fb13 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -287,7 +287,7 @@ private function contactArrayToEntry(array $contact): Entry { 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 f4fc7daf73aeb3b380fa5a00cee1fe6c46ec9a10 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 a9e0439f1fb13..d6ce2f0f2eaa4 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -287,7 +287,7 @@ private function contactArrayToEntry(array $contact): Entry { 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 36473a3f63a4e8485344666124bf142050593fa7 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 d6ce2f0f2eaa4..a0a14cd9cbd0e 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -285,8 +285,8 @@ private function contactArrayToEntry(array $contact): Entry { $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 47e950dbee1407ec3323fed25237ecd0842f1b8b 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 aa609aedbb9e7..dfdd67fbb2329 100644 --- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php +++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php @@ -140,6 +140,10 @@ public function testGetContactsHidesOwnEntry() { 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 @@ public function testGetContactsWithoutBinaryImage() { $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() {