|
11 | 11 | use OC\FilesMetadata\Model\FilesMetadata; |
12 | 12 | use OCA\DAV\Connector\Sabre\Exception\InvalidPath; |
13 | 13 | use OCA\Files_Sharing\External\Mount as SharingExternalMount; |
| 14 | +use OCP\Accounts\IAccountManager; |
14 | 15 | use OCP\Constants; |
15 | 16 | use OCP\Files\ForbiddenException; |
16 | 17 | use OCP\Files\IFilenameValidator; |
@@ -91,6 +92,7 @@ public function __construct( |
91 | 92 | private IPreview $previewManager, |
92 | 93 | private IUserSession $userSession, |
93 | 94 | private IFilenameValidator $validator, |
| 95 | + private IAccountManager $accountManager, |
94 | 96 | private bool $isPublic = false, |
95 | 97 | private bool $downloadAttachment = true, |
96 | 98 | ) { |
@@ -361,9 +363,26 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) |
361 | 363 | $owner = $node->getOwner(); |
362 | 364 | if (!$owner) { |
363 | 365 | return null; |
364 | | - } else { |
| 366 | + } |
| 367 | + |
| 368 | + // Get current user to see if we're in a public share or not |
| 369 | + $user = $this->userSession->getUser(); |
| 370 | + |
| 371 | + // If the user is logged in, we can return the display name |
| 372 | + if ($user !== null) { |
365 | 373 | return $owner->getDisplayName(); |
366 | 374 | } |
| 375 | + |
| 376 | + // Check if the user published their display name |
| 377 | + $ownerAccount = $this->accountManager->getAccount($owner); |
| 378 | + $ownerNameProperty = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME); |
| 379 | + |
| 380 | + // If not logged in, we need to have at least the published scope |
| 381 | + if ($user === null && $ownerNameProperty->getScope() === IAccountManager::SCOPE_PUBLISHED) { |
| 382 | + return $owner->getDisplayName(); |
| 383 | + } |
| 384 | + |
| 385 | + return null; |
367 | 386 | }); |
368 | 387 |
|
369 | 388 | $propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) { |
|
0 commit comments