Skip to content

Commit

Permalink
Merge pull request #36752 from nextcloud/backport/36735/stable25
Browse files Browse the repository at this point in the history
[stable25] fix the contacts-menu vcf-contact avatars
  • Loading branch information
nickvergessen authored Feb 24, 2023
2 parents 193e51d + f2885b3 commit e884498
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/private/Contacts/ContactsMenu/ContactsStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,13 @@ private function contactArrayToEntry(array $contact): Entry {
if (isset($contact['UID'])) {
$uid = $contact['UID'];
$entry->setId($uid);
$avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]);
if (isset($contact['isLocalSystemBook'])) {
$avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]);
} elseif (isset($contact['FN'])) {
$avatar = $this->urlGenerator->linkToRouteAbsolute('core.GuestAvatar.getAvatar', ['guestName' => $contact['FN'], 'size' => 64]);
} else {
$avatar = $this->urlGenerator->linkToRouteAbsolute('core.GuestAvatar.getAvatar', ['guestName' => $uid, 'size' => 64]);
}
$entry->setAvatar($avatar);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function testGetContactsWithoutBinaryImage() {
$user = $this->createMock(IUser::class);
$this->urlGenerator->expects($this->any())
->method('linkToRouteAbsolute')
->with('core.avatar.getAvatar', $this->anything())
->with('core.GuestAvatar.getAvatar', $this->anything())
->willReturn('https://urlToNcAvatar.test');
$this->contactsManager->expects($this->once())
->method('search')
Expand Down

0 comments on commit e884498

Please sign in to comment.