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

[stable24] fix: Fix avatar images #44742

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/private/Avatar/AvatarManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public function __construct(

/**
* return a user specific instance of \OCP\IAvatar
*
* If the user is disabled a guest avatar will be returned
*
* @see \OCP\IAvatar
* @param string $userId the ownCloud user id
* @return \OCP\IAvatar
Expand All @@ -114,6 +117,10 @@ public function getAvatar(string $userId) : IAvatar {
throw new \Exception('user does not exist');
}

if (!$user->isEnabled()) {
return $this->getGuestAvatar($userId);
}

// sanitize userID - fixes casing issue (needed for the filesystem stuff that is done below)
$userId = $user->getUID();

Expand Down
16 changes: 16 additions & 0 deletions tests/lib/Avatar/AvatarManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public function testGetAvatarForSelf() {
->method('getUID')
->willReturn('valid-user');

$user
->expects($this->any())
->method('isEnabled')
->willReturn(true);

// requesting user
$this->userSession->expects($this->once())
->method('getUser')
Expand Down Expand Up @@ -161,6 +166,11 @@ public function testGetAvatarValidUserDifferentCasing() {
->method('getUID')
->willReturn('valid-user');

$user
->expects($this->any())
->method('isEnabled')
->willReturn(true);

$this->userSession->expects($this->once())
->method('getUser')
->willReturn($user);
Expand Down Expand Up @@ -230,6 +240,12 @@ public function testGetAvatarScopes($avatarScope, $isPublicCall, $isKnownUser, $
->expects($this->once())
->method('getUID')
->willReturn('valid-user');

$user
->expects($this->any())
->method('isEnabled')
->willReturn(true);

$this->userManager
->expects($this->once())
->method('get')
Expand Down
Loading