Skip to content

Fix User profile picture when performing the search - #32635

Merged
blizzz merged 5 commits into
nextcloud:masterfrom
AndyXheli:patch-3
Oct 5, 2022
Merged

Fix User profile picture when performing the search#32635
blizzz merged 5 commits into
nextcloud:masterfrom
AndyXheli:patch-3

Conversation

@AndyXheli

Copy link
Copy Markdown
Contributor

Signed-off-by: Andy Xheli axheli@axtsolutions.com

Before
image

After
2022-05-27 14_47_23-Dashboard - AXTSolutions Cloud

Fix for #31065

@szaimenszaimen added bug 3. to review Waiting for reviews labels Jun 9, 2022
@szaimenszaimen added this to the Nextcloud 25 milestone Jun 9, 2022
@szaimen
szaimen requested review from a team, ArtificialOwl, CarlSchwan and juliusknorr and removed request for a teamJune 9, 2022 13:33
if (isset($contact['UID'])) {
$entry->setId($contact['UID']);
$uid = $contact['UID'];
$avatar = "/index.php/avatar/$uid/64";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This url should probably be built using IURLGenerator and we might need to have special handling for the viability settings, but the change in general makes sense I think.

@nickvergessen Didn't you mention a while back in chat a case on our instance where the contacts menu endpoint was not returning an avatar for a user? Could be related

This was referenced Aug 12, 2022
This was referenced Aug 24, 2022
@AndyXheli

Copy link
Copy Markdown
ContributorAuthor

Hey guys! Anyway we can look into this also. I think it would be nice to have this in NC 25.

Currently in NC 25

image

@AndyXheli
AndyXheli requested review from juliusknorr and removed request for ArtificialOwl and CarlSchwanSeptember 3, 2022 15:28
This was referenced Sep 6, 2022
@skjnldsvskjnldsv mentioned this pull request Sep 15, 2022
Comment threadlib/private/Contacts/ContactsMenu/ContactsStore.php Outdated
Signed-off-by: Andy Xheli <axheli@axtsolutions.com>
Co-authored-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Andy Xheli <axheli@axtsolutions.com>
Comment threadlib/private/Contacts/ContactsMenu/ContactsStore.php Outdated
Comment threadlib/private/Contacts/ContactsMenu/ContactsStore.php Outdated

@AndyXheliAndyXheli left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Andy Xheli axheli@axtsolutions.com

Tested on NC 24 & 25 and it works as it should

Signed-off-by: Andy Xheli <axheli@axtsolutions.com>
@AndyXheli

Copy link
Copy Markdown
ContributorAuthor

Hi all, any updates on this on being in NC 25 ?

@blizzz

Copy link
Copy Markdown
Member

@AndyXheli CI is unhappy:

There was 1 failure:

  1. Tests\Contacts\ContactsMenu\ContactsStoreTest::testGetContactsWithoutBinaryImage
    Failed asserting that '' is null.

/drone/src/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php:166

that test needs adjustements apparently

@AndyXheli

AndyXheli commented Sep 29, 2022

Copy link
Copy Markdown
ContributorAuthor

Thank you! @blizzz

@Pytal Do you have any suggestions on what needs to be done on ?

There was 1 failure:

Tests\Contacts\ContactsMenu\ContactsStoreTest::testGetContactsWithoutBinaryImage
Failed asserting that '' is null.
/drone/src/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php:166

@Pytal

Copy link
Copy Markdown
Member

This looks to be from the return value of linkToRouteAbsolute() so would say that urlGenerator needs to be mocked, @blizzz might know more here though?

@blizzz

Copy link
Copy Markdown
Member

Actually the test was ensuring(!) that avatar is null. Now it is not anymore as every time an avatar url is being created. The mock would at least return an empty string, and not null. testGetContactsWithoutAvatarURI does not fail however? A bit confusing when your not totally in the logic, it feels a bit that the tests were out of touch with the changes of the ContactsStore.

@blizzz

Copy link
Copy Markdown
Member

Best probably to do as @Pytal suggested: mock url generator to return a dummy url and expect this.

Something like this

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() {

(didn't run tests against it)

@AndyXheli

AndyXheli commented Oct 1, 2022

Copy link
Copy Markdown
ContributorAuthor

Thanks @blizzz I created a pull request for the changes that you suggested for the test

#34386

@blizzz

Copy link
Copy Markdown
Member

@AndyXheli could you add them as commit to this PR?

Signed-off-by: Andy Xheli <axheli@axtsolutions.com>
@AndyXheli

Copy link
Copy Markdown
ContributorAuthor

@blizzz All done :)

@blizzz
blizzz merged commit 7d024bc into nextcloud:masterOct 5, 2022
@blizzz

Copy link
Copy Markdown
Member

/backport to stable25

@AndyXheli

Copy link
Copy Markdown
ContributorAuthor

@blizzz thank you! Can we also backpo this to NC 24 ?

@blizzz

Copy link
Copy Markdown
Member

/backport to stable24

@szaimen

Copy link
Copy Markdown
Contributor

This seemingly broke avatars of vcf-contacts.

See #36735

@AndyXheli

Copy link
Copy Markdown
ContributorAuthor

@szaimen would this also fix #34503 ? under See #36735

@szaimen

Copy link
Copy Markdown
Contributor

@szaimen would this also fix #34503 ?

No.

@AndyXheli

Copy link
Copy Markdown
ContributorAuthor

Okay, thanks. Just checking so we did have duplicate issues.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@AndyXheli@blizzz@Pytal@szaimen@nickvergessen@juliusknorr@CarlSchwan@skjnldsv