diff options
Diffstat (limited to 'lib/Sabre')
-rw-r--r-- | lib/Sabre/Album/AlbumPhoto.php | 3 | ||||
-rw-r--r-- | lib/Sabre/Album/AlbumRoot.php | 19 | ||||
-rw-r--r-- | lib/Sabre/Album/AlbumsHome.php | 17 | ||||
-rw-r--r-- | lib/Sabre/Album/PropFindPlugin.php | 15 | ||||
-rw-r--r-- | lib/Sabre/Album/PublicAlbumRoot.php | 2 | ||||
-rw-r--r-- | lib/Sabre/Album/PublicAlbumsHome.php | 51 | ||||
-rw-r--r-- | lib/Sabre/Album/SharedAlbumRoot.php | 5 | ||||
-rw-r--r-- | lib/Sabre/Album/SharedAlbumsHome.php | 18 | ||||
-rw-r--r-- | lib/Sabre/PhotosHome.php | 25 | ||||
-rw-r--r-- | lib/Sabre/PublicAlbumAuthBackend.php | 80 | ||||
-rw-r--r-- | lib/Sabre/PublicRootCollection.php | 87 | ||||
-rw-r--r-- | lib/Sabre/RootCollection.php | 6 |
12 files changed, 227 insertions, 101 deletions
diff --git a/lib/Sabre/Album/AlbumPhoto.php b/lib/Sabre/Album/AlbumPhoto.php index a5e51bff..832bcb97 100644 --- a/lib/Sabre/Album/AlbumPhoto.php +++ b/lib/Sabre/Album/AlbumPhoto.php @@ -137,6 +137,9 @@ class AlbumPhoto implements IFile { public function isFavorite(): bool { $tagManager = \OCP\Server::get(\OCP\ITagManager::class); $tagger = $tagManager->load('files'); + if ($tagger === null) { + return false; + } $tags = $tagger->getTagsForObjects([$this->getFileId()]); if ($tags === false || empty($tags)) { diff --git a/lib/Sabre/Album/AlbumRoot.php b/lib/Sabre/Album/AlbumRoot.php index 0406a8c3..0a10157b 100644 --- a/lib/Sabre/Album/AlbumRoot.php +++ b/lib/Sabre/Album/AlbumRoot.php @@ -31,7 +31,6 @@ use OCA\Photos\Service\UserConfigService; use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; -use OCP\IUser; use Sabre\DAV\Exception\Conflict; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\NotFound; @@ -43,22 +42,19 @@ class AlbumRoot implements ICollection, ICopyTarget { protected AlbumMapper $albumMapper; protected AlbumWithFiles $album; protected IRootFolder $rootFolder; - protected Folder $userFolder; - protected IUser $user; + protected string $userId; public function __construct( AlbumMapper $albumMapper, AlbumWithFiles $album, IRootFolder $rootFolder, - Folder $userFolder, - IUser $user, + string $userId, UserConfigService $userConfigService ) { $this->albumMapper = $albumMapper; $this->album = $album; $this->rootFolder = $rootFolder; - $this->userFolder = $userFolder; - $this->user = $user; + $this->userId = $userId; $this->userConfigService = $userConfigService; } @@ -82,7 +78,7 @@ class AlbumRoot implements ICollection, ICopyTarget { protected function getPhotosLocationInfo() { $photosLocation = $this->userConfigService->getUserConfig('photosLocation'); - $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); + $userFolder = $this->rootFolder->getUserFolder($this->userId); return [$photosLocation, $userFolder]; } @@ -160,23 +156,22 @@ class AlbumRoot implements ICollection, ICopyTarget { } public function copyInto($targetName, $sourcePath, INode $sourceNode): bool { - $uid = $this->user->getUID(); if ($sourceNode instanceof File) { $sourceId = $sourceNode->getId(); $ownerUID = $sourceNode->getFileInfo()->getOwner()->getUID(); return $this->addFile($sourceId, $ownerUID); } + $uid = $this->userId; throw new \Exception("Can't add file to album, only files from $uid can be added"); } protected function addFile(int $sourceId, string $ownerUID): bool { - $uid = $this->user->getUID(); if (in_array($sourceId, $this->album->getFileIds())) { throw new Conflict("File $sourceId is already in the folder"); } - if ($ownerUID === $uid) { + if ($ownerUID === $this->userId) { $this->albumMapper->addFile($this->album->getAlbum()->getId(), $sourceId, $ownerUID); - $node = current($this->userFolder->getById($sourceId)); + $node = current($this->rootFolder->getUserFolder($ownerUID)->getById($sourceId)); $this->album->addFile(new AlbumFile($sourceId, $node->getName(), $node->getMimetype(), $node->getSize(), $node->getMTime(), $node->getEtag(), $node->getCreationTime(), $ownerUID)); return true; } diff --git a/lib/Sabre/Album/AlbumsHome.php b/lib/Sabre/Album/AlbumsHome.php index c077eacd..d73e6da3 100644 --- a/lib/Sabre/Album/AlbumsHome.php +++ b/lib/Sabre/Album/AlbumsHome.php @@ -27,9 +27,7 @@ use OCA\Photos\Album\AlbumInfo; use OCA\Photos\Album\AlbumMapper; use OCA\Photos\Album\AlbumWithFiles; use OCA\Photos\Service\UserConfigService; -use OCP\Files\Folder; use OCP\Files\IRootFolder; -use OCP\IUser; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\ICollection; @@ -37,9 +35,8 @@ use Sabre\DAV\ICollection; class AlbumsHome implements ICollection { protected AlbumMapper $albumMapper; protected array $principalInfo; - protected IUser $user; + protected string $userId; protected IRootFolder $rootFolder; - protected Folder $userFolder; protected UserConfigService $userConfigService; public const NAME = 'albums'; @@ -52,15 +49,14 @@ class AlbumsHome implements ICollection { public function __construct( array $principalInfo, AlbumMapper $albumMapper, - IUser $user, + string $userId, IRootFolder $rootFolder, UserConfigService $userConfigService ) { $this->principalInfo = $principalInfo; $this->albumMapper = $albumMapper; - $this->user = $user; + $this->userId = $userId; $this->rootFolder = $rootFolder; - $this->userFolder = $rootFolder->getUserFolder($user->getUID()); $this->userConfigService = $userConfigService; } @@ -90,8 +86,7 @@ class AlbumsHome implements ICollection { * @return void */ public function createDirectory($name) { - $uid = $this->user->getUID(); - $this->albumMapper->create($uid, $name); + $this->albumMapper->create($this->userId, $name); } public function getChild($name) { @@ -109,9 +104,9 @@ class AlbumsHome implements ICollection { */ public function getChildren(): array { if ($this->children === null) { - $albumInfos = $this->albumMapper->getForUser($this->user->getUID()); + $albumInfos = $this->albumMapper->getForUser($this->userId); $this->children = array_map(function (AlbumInfo $albumInfo) { - return new AlbumRoot($this->albumMapper, new AlbumWithFiles($albumInfo, $this->albumMapper), $this->rootFolder, $this->userFolder, $this->user, $this->userConfigService); + return new AlbumRoot($this->albumMapper, new AlbumWithFiles($albumInfo, $this->albumMapper), $this->rootFolder, $this->userId, $this->userConfigService); }, $albumInfos); } diff --git a/lib/Sabre/Album/PropFindPlugin.php b/lib/Sabre/Album/PropFindPlugin.php index b716ca34..9f3572ce 100644 --- a/lib/Sabre/Album/PropFindPlugin.php +++ b/lib/Sabre/Album/PropFindPlugin.php @@ -28,13 +28,13 @@ use OCA\DAV\Connector\Sabre\FilesPlugin; use OCA\Photos\Album\AlbumMapper; use OCP\IConfig; use OCP\IPreview; +use OCP\Files\NotFoundException; use Sabre\DAV\INode; use Sabre\DAV\PropFind; use Sabre\DAV\PropPatch; use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; use Sabre\DAV\Tree; -use OCP\Files\NotFoundException; class PropFindPlugin extends ServerPlugin { public const ORIGINAL_NAME_PROPERTYNAME = '{http://nextcloud.org/ns}original-name'; @@ -69,6 +69,19 @@ class PropFindPlugin extends ServerPlugin { } /** + * Returns a plugin name. + * + * Using this name other plugins will be able to access other plugins + * using DAV\Server::getPlugin + * + * @return string + */ + public function getPluginName() { + return 'photosDavPlugin'; + } + + + /** * @return void */ public function initialize(Server $server) { diff --git a/lib/Sabre/Album/PublicAlbumRoot.php b/lib/Sabre/Album/PublicAlbumRoot.php index ab4e6fc4..54ccaa87 100644 --- a/lib/Sabre/Album/PublicAlbumRoot.php +++ b/lib/Sabre/Album/PublicAlbumRoot.php @@ -24,8 +24,6 @@ declare(strict_types=1); namespace OCA\Photos\Sabre\Album; use Sabre\DAV\Exception\Forbidden; -use Sabre\DAV\Exception\Conflict; -use OCP\Files\Folder; use Sabre\DAV\INode; class PublicAlbumRoot extends AlbumRoot { diff --git a/lib/Sabre/Album/PublicAlbumsHome.php b/lib/Sabre/Album/PublicAlbumsHome.php deleted file mode 100644 index a97597bd..00000000 --- a/lib/Sabre/Album/PublicAlbumsHome.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -declare(strict_types=1); -/** - * @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -namespace OCA\Photos\Sabre\Album; - -use Sabre\DAV\Exception\Forbidden; -use Sabre\DAV\Exception\NotFound; -use OCA\Photos\Album\AlbumMapper; - -class PublicAlbumsHome extends AlbumsHome { - public const NAME = 'public'; - - /** - * @return never - */ - public function createDirectory($name) { - throw new Forbidden('Not allowed to create folders in this folder'); - } - - public function getChild($name) { - $albums = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($name, AlbumMapper::TYPE_LINK); - - $albums = array_filter($albums, fn ($album) => $album->getAlbum()->getUserId() === $this->user->getUid()); - - if (count($albums) !== 1) { - throw new NotFound(); - } - - return new PublicAlbumRoot($this->albumMapper, $albums[0], $this->rootFolder, $this->userFolder, $this->user, $this->userConfigService); - } -} diff --git a/lib/Sabre/Album/SharedAlbumRoot.php b/lib/Sabre/Album/SharedAlbumRoot.php index 25caf87a..d5dc9909 100644 --- a/lib/Sabre/Album/SharedAlbumRoot.php +++ b/lib/Sabre/Album/SharedAlbumRoot.php @@ -32,7 +32,7 @@ class SharedAlbumRoot extends AlbumRoot { * @return void */ public function delete() { - $this->albumMapper->deleteUserFromAlbumCollaboratorsList($this->user->getUID(), $this->album->getAlbum()->getId()); + $this->albumMapper->deleteUserFromAlbumCollaboratorsList($this->userId, $this->album->getAlbum()->getId()); } /** @@ -51,8 +51,7 @@ class SharedAlbumRoot extends AlbumRoot { fn ($collaborator) => $collaborator['type'].':'.$collaborator['id'], $this->albumMapper->getCollaborators($this->album->getAlbum()->getId()), ); - $uid = $this->user->getUID(); - if (!in_array(AlbumMapper::TYPE_USER.':'.$uid, $collaboratorIds)) { + if (!in_array(AlbumMapper::TYPE_USER.':'.$this->userId, $collaboratorIds)) { return false; } diff --git a/lib/Sabre/Album/SharedAlbumsHome.php b/lib/Sabre/Album/SharedAlbumsHome.php index c4665a17..136ae66b 100644 --- a/lib/Sabre/Album/SharedAlbumsHome.php +++ b/lib/Sabre/Album/SharedAlbumsHome.php @@ -26,12 +26,13 @@ namespace OCA\Photos\Sabre\Album; use OCA\Photos\Album\AlbumWithFiles; use OCA\Photos\Service\UserConfigService; use Sabre\DAV\Exception\Forbidden; +use OCP\IUserManager; use OCP\IGroupManager; use OCA\Photos\Album\AlbumMapper; use OCP\Files\IRootFolder; -use OCP\IUser; class SharedAlbumsHome extends AlbumsHome { + private IUserManager $userManager; private IGroupManager $groupManager; public const NAME = 'sharedalbums'; @@ -39,19 +40,21 @@ class SharedAlbumsHome extends AlbumsHome { public function __construct( array $principalInfo, AlbumMapper $albumMapper, - IUser $user, + string $userId, IRootFolder $rootFolder, + IUserManager $userManager, IGroupManager $groupManager, UserConfigService $userConfigService ) { parent::__construct( $principalInfo, $albumMapper, - $user, + $userId, $rootFolder, $userConfigService ); + $this->userManager = $userManager; $this->groupManager = $groupManager; } @@ -67,17 +70,18 @@ class SharedAlbumsHome extends AlbumsHome { */ public function getChildren(): array { if ($this->children === null) { - $albums = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($this->user->getUID(), AlbumMapper::TYPE_USER); + $albums = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($this->userId, AlbumMapper::TYPE_USER); - $userGroups = $this->groupManager->getUserGroupIds($this->user); + $user = $this->userManager->get($this->userId); + $userGroups = $this->groupManager->getUserGroupIds($user); foreach ($userGroups as $groupId) { $albumsForGroup = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($groupId, AlbumMapper::TYPE_GROUP); $albumsForGroup = array_udiff($albumsForGroup, $albums, fn ($a, $b) => $a->getAlbum()->getId() - $b->getAlbum()->getId()); $albums = array_merge($albums, $albumsForGroup); } - $this->children = array_map(function (AlbumWithFiles $folder) { - return new SharedAlbumRoot($this->albumMapper, $folder, $this->rootFolder, $this->userFolder, $this->user, $this->userConfigService); + $this->children = array_map(function (AlbumWithFiles $album) { + return new SharedAlbumRoot($this->albumMapper, $album, $this->rootFolder, $this->userId, $this->userConfigService); }, $albums); } diff --git a/lib/Sabre/PhotosHome.php b/lib/Sabre/PhotosHome.php index 97106c44..fc2e6b4c 100644 --- a/lib/Sabre/PhotosHome.php +++ b/lib/Sabre/PhotosHome.php @@ -26,10 +26,9 @@ namespace OCA\Photos\Sabre; use OCA\Photos\Album\AlbumMapper; use OCA\Photos\Sabre\Album\AlbumsHome; use OCA\Photos\Sabre\Album\SharedAlbumsHome; -use OCA\Photos\Sabre\Album\PublicAlbumsHome; use OCA\Photos\Service\UserConfigService; use OCP\Files\IRootFolder; -use OCP\IUser; +use OCP\IUserManager; use OCP\IGroupManager; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\NotFound; @@ -38,23 +37,26 @@ use Sabre\DAV\ICollection; class PhotosHome implements ICollection { private AlbumMapper $albumMapper; private array $principalInfo; - private IUser $user; + private string $userId; private IRootFolder $rootFolder; + private IUserManager $userManager; private IGroupManager $groupManager; private UserConfigService $userConfigService; public function __construct( array $principalInfo, AlbumMapper $albumMapper, - IUser $user, + string $userId, IRootFolder $rootFolder, + IUserManager $userManager, IGroupManager $groupManager, UserConfigService $userConfigService ) { $this->principalInfo = $principalInfo; $this->albumMapper = $albumMapper; - $this->user = $user; + $this->userId = $userId; $this->rootFolder = $rootFolder; + $this->userManager = $userManager; $this->groupManager = $groupManager; $this->userConfigService = $userConfigService; } @@ -92,11 +94,9 @@ class PhotosHome implements ICollection { public function getChild($name) { switch ($name) { case AlbumsHome::NAME: - return new AlbumsHome($this->principalInfo, $this->albumMapper, $this->user, $this->rootFolder, $this->userConfigService); + return new AlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userConfigService); case SharedAlbumsHome::NAME: - return new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->user, $this->rootFolder, $this->groupManager, $this->userConfigService); - case PublicAlbumsHome::NAME: - return new PublicAlbumsHome($this->principalInfo, $this->albumMapper, $this->user, $this->rootFolder, $this->userConfigService); + return new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService); } throw new NotFound(); @@ -107,14 +107,13 @@ class PhotosHome implements ICollection { */ public function getChildren(): array { return [ - new AlbumsHome($this->principalInfo, $this->albumMapper, $this->user, $this->rootFolder, $this->userConfigService), - new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->user, $this->rootFolder, $this->groupManager, $this->userConfigService), - new PublicAlbumsHome($this->principalInfo, $this->albumMapper, $this->user, $this->rootFolder, $this->userConfigService), + new AlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userConfigService), + new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService), ]; } public function childExists($name): bool { - return $name === AlbumsHome::NAME || $name === SharedAlbumsHome::NAME || $name === PublicAlbumsHome::NAME; + return $name === AlbumsHome::NAME || $name === SharedAlbumsHome::NAME; } public function getLastModified(): int { diff --git a/lib/Sabre/PublicAlbumAuthBackend.php b/lib/Sabre/PublicAlbumAuthBackend.php new file mode 100644 index 00000000..bbf84f50 --- /dev/null +++ b/lib/Sabre/PublicAlbumAuthBackend.php @@ -0,0 +1,80 @@ +<?php +/** + * @copyright Copyright (c) 2022 Louis Chmn <louis@chmn.me> + * + * @author Louis Chmn <louis@chmn.me> + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace OCA\Photos\Sabre; + +use OC\Security\Bruteforce\Throttler; +use OCA\Photos\Album\AlbumMapper; +use OCA\Photos\Album\AlbumWithFiles; +use OCP\IRequest; +use Sabre\DAV\Auth\Backend\AbstractBasic; + +class PublicAlbumAuthBackend extends AbstractBasic { + private const BRUTEFORCE_ACTION = 'public_webdav_auth'; + private ?AlbumWithFiles $album = null; + private IRequest $request; + private AlbumMapper $albumMapper; + private Throttler $throttler; + + public function __construct( + IRequest $request, + AlbumMapper $albumMapper, + Throttler $throttler + ) { + $this->request = $request; + $this->albumMapper = $albumMapper; + $this->throttler = $throttler; + + // setup realm + $defaults = new \OCP\Defaults(); + $this->realm = $defaults->getName(); + } + + /** + * Validates the token. + * + * @param string $username + * @return bool + * @throws \Sabre\DAV\Exception\NotAuthenticated + */ + protected function validateUserPass($username, $password) { + $this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), self::BRUTEFORCE_ACTION); + + $albums = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($username, AlbumMapper::TYPE_LINK); + + + if (count($albums) !== 1) { + $this->throttler->registerAttempt(self::BRUTEFORCE_ACTION, $this->request->getRemoteAddress()); + return false; + } + + $this->album = $albums[0]; + + \OC_User::setIncognitoMode(true); + + return true; + } + + public function getShare(): AlbumWithFiles { + assert($this->album !== null); + return $this->album; + } +} diff --git a/lib/Sabre/PublicRootCollection.php b/lib/Sabre/PublicRootCollection.php new file mode 100644 index 00000000..e8b6bf50 --- /dev/null +++ b/lib/Sabre/PublicRootCollection.php @@ -0,0 +1,87 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Photos\Sabre; + +use OCA\Photos\Album\AlbumMapper; +use OCA\Photos\Sabre\Album\PublicAlbumRoot; +use OCA\Photos\Service\UserConfigService; +use OCP\Files\IRootFolder; +use Sabre\DAVACL\AbstractPrincipalCollection; +use Sabre\DAVACL\PrincipalBackend; +use Sabre\DAV\Exception\NotFound; + +class PublicRootCollection extends AbstractPrincipalCollection { + private AlbumMapper $albumMapper; + private IRootFolder $rootFolder; + private UserConfigService $userConfigService; + + public function __construct( + AlbumMapper $albumMapper, + IRootFolder $rootFolder, + PrincipalBackend\BackendInterface $principalBackend, + UserConfigService $userConfigService + ) { + parent::__construct($principalBackend, 'principals/token'); + + $this->albumMapper = $albumMapper; + $this->rootFolder = $rootFolder; + $this->userConfigService = $userConfigService; + } + + public function getName(): string { + return 'photospublic'; + } + + /** + * Child are retrieved directly by getChild. + * This should never be called. + * @param array $principalInfo + */ + public function getChildForPrincipal(array $principalInfo): PublicAlbumRoot { + throw new \Sabre\DAV\Exception\Forbidden(); + } + + /** + * Returns a child object, by its token. + * + * @param string $token + * + * @throws NotFound + * + * @return DAV\INode + */ + public function getChild($token) { + if (is_null($token)) { + throw new \Sabre\DAV\Exception\Forbidden(); + } + + $albums = $this->albumMapper->getSharedAlbumsForCollaboratorWithFiles($token, AlbumMapper::TYPE_LINK); + + if (count($albums) !== 1) { + throw new NotFound("Unable to find public album"); + } + + return new PublicAlbumRoot($this->albumMapper, $albums[0], $this->rootFolder, $albums[0]->getAlbum()->getUserId(), $this->userConfigService); + } +} diff --git a/lib/Sabre/RootCollection.php b/lib/Sabre/RootCollection.php index 2e879f9d..8bcb42c7 100644 --- a/lib/Sabre/RootCollection.php +++ b/lib/Sabre/RootCollection.php @@ -29,12 +29,14 @@ use OCP\Files\IRootFolder; use OCP\IUserSession; use Sabre\DAVACL\AbstractPrincipalCollection; use Sabre\DAVACL\PrincipalBackend; +use OCP\IUserManager; use OCP\IGroupManager; class RootCollection extends AbstractPrincipalCollection { private AlbumMapper $folderMapper; private IUserSession $userSession; private IRootFolder $rootFolder; + private IUserManager $userManager; private IGroupManager $groupManager; private UserConfigService $userConfigService; @@ -43,6 +45,7 @@ class RootCollection extends AbstractPrincipalCollection { IUserSession $userSession, IRootFolder $rootFolder, PrincipalBackend\BackendInterface $principalBackend, + IUserManager $userManager, IGroupManager $groupManager, UserConfigService $userConfigService ) { @@ -51,6 +54,7 @@ class RootCollection extends AbstractPrincipalCollection { $this->folderMapper = $folderMapper; $this->userSession = $userSession; $this->rootFolder = $rootFolder; + $this->userManager = $userManager; $this->groupManager = $groupManager; $this->userConfigService = $userConfigService; } @@ -70,7 +74,7 @@ class RootCollection extends AbstractPrincipalCollection { if (is_null($user) || $name !== $user->getUID()) { throw new \Sabre\DAV\Exception\Forbidden(); } - return new PhotosHome($principalInfo, $this->folderMapper, $user, $this->rootFolder, $this->groupManager, $this->userConfigService); + return new PhotosHome($principalInfo, $this->folderMapper, $name, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService); } public function getName(): string { |