diff options
Diffstat (limited to 'apps/dav/lib/Connector')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/FilesPlugin.php | 21 | ||||
-rw-r--r-- | apps/dav/lib/Connector/Sabre/ServerFactory.php | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index 34f48384e12..b886534f9de 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -11,6 +11,7 @@ use OC\AppFramework\Http\Request; use OC\FilesMetadata\Model\FilesMetadata; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; use OCA\Files_Sharing\External\Mount as SharingExternalMount; +use OCP\Accounts\IAccountManager; use OCP\Constants; use OCP\Files\ForbiddenException; use OCP\Files\IFilenameValidator; @@ -91,6 +92,7 @@ class FilesPlugin extends ServerPlugin { private IPreview $previewManager, private IUserSession $userSession, private IFilenameValidator $validator, + private IAccountManager $accountManager, private bool $isPublic = false, private bool $downloadAttachment = true, ) { @@ -361,9 +363,26 @@ class FilesPlugin extends ServerPlugin { $owner = $node->getOwner(); if (!$owner) { return null; - } else { + } + + // Get current user to see if we're in a public share or not + $user = $this->userSession->getUser(); + + // If the user is logged in, we can return the display name + if ($user !== null) { return $owner->getDisplayName(); } + + // Check if the user published their display name + $ownerAccount = $this->accountManager->getAccount($owner); + $ownerNameProperty = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME); + + // Since we are not logged in, we need to have at least the published scope + if ($ownerNameProperty->getScope() === IAccountManager::SCOPE_PUBLISHED) { + return $owner->getDisplayName(); + } + + return null; }); $propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) { diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php index f035ff8d625..55cbb416457 100644 --- a/apps/dav/lib/Connector/Sabre/ServerFactory.php +++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php @@ -14,6 +14,7 @@ use OCA\DAV\DAV\CustomPropertiesBackend; use OCA\DAV\DAV\ViewOnlyPlugin; use OCA\DAV\Files\BrowserErrorPagePlugin; use OCA\Theming\ThemingDefaults; +use OCP\Accounts\IAccountManager; use OCP\App\IAppManager; use OCP\Comments\ICommentsManager; use OCP\EventDispatcher\IEventDispatcher; @@ -128,6 +129,7 @@ class ServerFactory { $this->previewManager, $this->userSession, \OCP\Server::get(IFilenameValidator::class), + \OCP\Server::get(IAccountManager::class), false, !$this->config->getSystemValue('debug', false) ) |