diff options
Diffstat (limited to 'lib/private/avatarmanager.php')
-rw-r--r-- | lib/private/avatarmanager.php | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/private/avatarmanager.php b/lib/private/avatarmanager.php index 143874b6be3..6969b386e15 100644 --- a/lib/private/avatarmanager.php +++ b/lib/private/avatarmanager.php @@ -27,13 +27,33 @@ namespace OC; use OCP\IAvatarManager; -use OC\Avatar; +use OCP\IUserManager; +use OCP\Files\IRootFolder; +use OCP\IL10N; /** * This class implements methods to access Avatar functionality */ class AvatarManager implements IAvatarManager { + /** @var IUserManager */ + private $userManager; + + /** @var IRootFolder */ + private $rootFolder; + + /** @var IL10N */ + private $l; + + public function __construct( + IUserManager $userManager, + IRootFolder $rootFolder, + IL10N $l) { + $this->userManager = $userManager; + $this->rootFolder = $rootFolder; + $this->l = $l; + } + /** * return a user specific instance of \OCP\IAvatar * @see \OCP\IAvatar @@ -42,6 +62,9 @@ class AvatarManager implements IAvatarManager { * @throws \Exception In case the username is potentially dangerous */ public function getAvatar($user) { - return new Avatar($user); + if (!$this->userManager->userExists($user)) { + throw new \Exception('user does not exist'); + } + return new Avatar($this->rootFolder->getUserFolder($user)->getParent(), $this->l); } } |