Skip to content
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
18 changes: 18 additions & 0 deletions build/integration/features/avatar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,21 @@ Feature: avatar
| Content-Type | image/png |
And last avatar is a square of size 512
And last avatar is not a single color

Scenario: Get avatar for users with cloudID formatted user id
Given user "user@example.tld" exists
Given Logging in using web as "user@example.tld"
When logged in user posts avatar from file "data/green-square-256.png"
And user "user@example.tld" gets avatar for user "user@example.tld"
And The following headers should be set
| Content-Type | image/png |
| X-NC-IsCustomAvatar | 1 |
# Last avatar size is 512 by default when getting avatar without size parameter
And last avatar is a square of size 512
And last avatar is a single "#00FF00" color
And user "anonymous" gets avatar for user "user@example.tld"
And The following headers should be set
| Content-Type | image/png |
| X-NC-IsCustomAvatar | 1 |
And last avatar is a square of size 512
And last avatar is a single "#00FF00" color
10 changes: 5 additions & 5 deletions lib/private/Avatar/AvatarManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ public function __construct(
* If the user is disabled a guest avatar will be returned
*
* @see \OCP\IAvatar
* @param string $userId the ownCloud user id
* @param string $userId the user id
* @throws \Exception In case the username is potentially dangerous
* @throws NotFoundException In case there is no user folder yet
*/
#[\Override]
public function getAvatar(string $userId): IAvatar {
if ($this->cloudIdManager->isValidCloudId($userId)) {
return $this->getRemoteAvatar($userId);
}

$user = $this->userManager->get($userId);
if ($user === null) {
if ($this->cloudIdManager->isValidCloudId($userId)) {
return $this->getRemoteAvatar($userId);
}

throw new \Exception('user does not exist');
}

Expand Down
5 changes: 3 additions & 2 deletions tests/lib/Avatar/AvatarManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ public function testGetAvatarForRemoteUser(): void {
$cloudId = 'user@https://remote.example.com';

$this->userManager
->expects($this->never())
->method('get');
->expects($this->once())
->method('get')
->willReturn(null);

$resolvedCloudId = $this->createMock(ICloudId::class);
$resolvedCloudId->method('getUser')->willReturn('user');
Expand Down
Loading