Unverified Commit 97669c5d authored by Vincent Petry's avatar Vincent Petry
Browse files

Change getAvatarFolder to accept user object

This is to make sure we don't get into user id casing issues.
parent 5415cade
......@@ -33,6 +33,7 @@ use OCP\ILogger;
use OCP\IUserManager;
use OCP\Files\IRootFolder;
use OCP\IL10N;
use OCP\IUser;
/**
* This class implements methods to access Avatar functionality
......@@ -86,7 +87,7 @@ class AvatarManager implements IAvatarManager {
$userId = $user->getUID();
$avatarsFolder = $this->getAvatarFolder($userId);
$avatarsFolder = $this->getAvatarFolder($user);
return new Avatar($avatarsFolder, $this->l, $user, $this->logger);
}
......@@ -106,14 +107,14 @@ class AvatarManager implements IAvatarManager {
/**
* Returns the avatar folder for the given user
*
* @param $userId user id
* @param IUser $user user
* @return Folder|\OCP\Files\Node
*
* @internal
*/
public function getAvatarFolder($userId) {
public function getAvatarFolder(IUser $user) {
$avatarsFolder = $this->getFolder($this->rootFolder, 'avatars');
$parts = $this->buildAvatarPath($userId);
$parts = $this->buildAvatarPath($user->getUID());
foreach ($parts as $part) {
$avatarsFolder = $this->getFolder($avatarsFolder, $part);
}
......
......@@ -110,7 +110,7 @@ class MoveAvatarOutsideHome implements IRepairStep {
$oldAvatarUserFolder = $this->rootFolder->get('/' . $userId);
$oldAvatar = new Avatar($oldAvatarUserFolder, $this->l, $user, $this->logger);
if ($oldAvatar->exists()) {
$newAvatarsUserFolder = $this->avatarManager->getAvatarFolder($userId);
$newAvatarsUserFolder = $this->avatarManager->getAvatarFolder($user);
// get original file
$oldAvatarFile = $oldAvatar->getFile(-1);
......
......@@ -120,7 +120,7 @@ class AvatarManagerTest extends TestCase {
$folder = $this->createMock(Folder::class);
$this->avatarManager->expects($this->once())
->method('getAvatarFolder')
->with('valid-user')
->with($user)
->willReturn($folder);
$avatar = $this->avatarManager->getAvatar('vaLid-USER');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment