Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix User profile picture when performing the search #32635

Merged
merged 5 commits into from Oct 5, 2022
Merged

Fix User profile picture when performing the search #32635

merged 5 commits into from Oct 5, 2022

Conversation

ghost
Copy link

@ghost ghost commented May 27, 2022

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

Before
image

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

Fix for #31065

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

ghost commented Sep 2, 2022

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

@ghost ghost requested review from juliusknorr and removed request for ArtificialOwl and CarlSchwan September 3, 2022 15:28
This was referenced Sep 6, 2022
@skjnldsv skjnldsv mentioned this pull request Sep 15, 2022
Signed-off-by: Andy Xheli <axheli@axtsolutions.com>

Co-authored-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Andy Xheli <axheli@axtsolutions.com>
Copy link
Author

@ghost ghost left a comment

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>
@ghost
Copy link
Author

ghost commented Sep 26, 2022

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

@ghost ghost mentioned this pull request Sep 28, 2022
@blizzz
Copy link
Member

blizzz commented Sep 29, 2022

@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

@ghost
Copy link
Author

ghost commented Sep 29, 2022

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
Member

Pytal commented Sep 29, 2022

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
Member

blizzz commented Oct 1, 2022

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
Member

blizzz commented Oct 1, 2022

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)

@ghost
Copy link
Author

ghost commented Oct 1, 2022

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

#34386

@ghost ghost mentioned this pull request Oct 2, 2022
@blizzz
Copy link
Member

blizzz commented Oct 3, 2022

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

Signed-off-by: Andy Xheli <axheli@axtsolutions.com>
@ghost
Copy link
Author

ghost commented Oct 3, 2022

@blizzz All done :)

@blizzz blizzz merged commit 7d024bc into nextcloud:master Oct 5, 2022
@blizzz
Copy link
Member

blizzz commented Oct 5, 2022

/backport to stable25

@ghost
Copy link
Author

ghost commented Oct 5, 2022

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

@blizzz
Copy link
Member

blizzz commented Oct 5, 2022

/backport to stable24

@szaimen
Copy link
Contributor

szaimen commented Feb 15, 2023

This seemingly broke avatars of vcf-contacts.

See #36735

@ghost
Copy link
Author

ghost commented Feb 15, 2023

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

@szaimen
Copy link
Contributor

szaimen commented Feb 15, 2023

@szaimen would this also fix #34503 ?

No.

@ghost
Copy link
Author

ghost commented Feb 15, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants