mirror of https://github.com/nextcloud/server
Merge pull request #32635 from andyxheli/patch-3
Fix User profile picture when performing the search
This commit is contained in:
commit
7d024bc337
|
@ -284,8 +284,11 @@ class ContactsStore implements IContactsStore {
|
||||||
private function contactArrayToEntry(array $contact): Entry {
|
private function contactArrayToEntry(array $contact): Entry {
|
||||||
$entry = new Entry();
|
$entry = new Entry();
|
||||||
|
|
||||||
if (isset($contact['id'])) {
|
if (isset($contact['UID'])) {
|
||||||
$entry->setId($contact['id']);
|
$uid = $contact['UID'];
|
||||||
|
$entry->setId($uid);
|
||||||
|
$avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]);
|
||||||
|
$entry->setAvatar($avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($contact['FN'])) {
|
if (isset($contact['FN'])) {
|
||||||
|
|
|
@ -140,6 +140,10 @@ class ContactsStoreTest extends TestCase {
|
||||||
public function testGetContactsWithoutBinaryImage() {
|
public function testGetContactsWithoutBinaryImage() {
|
||||||
/** @var IUser|MockObject $user */
|
/** @var IUser|MockObject $user */
|
||||||
$user = $this->createMock(IUser::class);
|
$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())
|
$this->contactsManager->expects($this->once())
|
||||||
->method('search')
|
->method('search')
|
||||||
->with($this->equalTo(''), $this->equalTo(['FN', 'EMAIL']))
|
->with($this->equalTo(''), $this->equalTo(['FN', 'EMAIL']))
|
||||||
|
@ -163,7 +167,7 @@ class ContactsStoreTest extends TestCase {
|
||||||
$entries = $this->contactsStore->getContacts($user, '');
|
$entries = $this->contactsStore->getContacts($user, '');
|
||||||
|
|
||||||
$this->assertCount(2, $entries);
|
$this->assertCount(2, $entries);
|
||||||
$this->assertNull($entries[1]->getAvatar());
|
$this->assertSame('https://urlToNcAvatar.test', $entries[1]->getAvatar());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetContactsWithoutAvatarURI() {
|
public function testGetContactsWithoutAvatarURI() {
|
||||||
|
|
Loading…
Reference in New Issue