Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1096,16 +1096,10 @@ private function createShare($data) {

if ($share->getShareType() === IShare::TYPE_USER) {
$share->setSharedWith($data['share_with']);
$displayName = $this->userManager->getDisplayName($data['share_with']);
if ($displayName !== null) {
$share->setSharedWithDisplayName($displayName);
}
$share->setSharedWithDisplayNameCallback(fn (IShare $share) => $this->userManager->getDisplayName($share->getSharedWith()));
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$share->setSharedWith($data['share_with']);
$group = $this->groupManager->get($data['share_with']);
if ($group !== null) {
$share->setSharedWithDisplayName($group->getDisplayName());
}
$share->setSharedWithDisplayNameCallback(fn (IShare $share) => $this->groupManager->getDisplayName($share->getSharedWith()));
} elseif ($share->getShareType() === IShare::TYPE_LINK) {
$share->setPassword($data['password']);
$share->setSendPasswordByTalk((bool)$data['password_by_talk']);
Expand Down Expand Up @@ -1462,6 +1456,7 @@ public function getAccessList($nodes, $currentAccess) {

/**
* For each user the path with the fewest slashes is returned
*
* @param array $shares
* @return array
*/
Expand Down
19 changes: 15 additions & 4 deletions lib/private/Share20/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class Share implements IShare {
private $shareType;
/** @var string */
private $sharedWith;
/** @var string */
private $sharedWithDisplayName;
private ?string $sharedWithDisplayName = null;
/** @var ?callable */
private $sharedWithDisplayNameCallback = null;
/** @var string */
private $sharedWithAvatar;
/** @var string */
Expand Down Expand Up @@ -247,10 +248,20 @@ public function setSharedWithDisplayName($displayName) {
}

/**
* @inheritdoc
* @param callable(IShare):?string $callback
* @return $this
*/
public function setSharedWithDisplayNameCallback(callable $callback) {
$this->sharedWithDisplayNameCallback = $callback;
return $this;
}

public function getSharedWithDisplayName() {
return $this->sharedWithDisplayName;
if ($this->sharedWithDisplayNameCallback !== null) {
$this->sharedWithDisplayName = ($this->sharedWithDisplayNameCallback)($this);
$this->sharedWithDisplayNameCallback = null;
}
return $this->sharedWithDisplayName ?? $this->sharedWith;
}

/**
Expand Down
Loading