Skip to content
Closed
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
49 changes: 40 additions & 9 deletions lib/ShareByCircleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,6 @@ public function deleteFromSelf(IShare $share, $recipient): void {
}
}

/**
* @param IShare $share
* @param string $recipient
*
* @return IShare
*/
public function restore(IShare $share, string $recipient): IShare {
return $share;
}

/**
* @param IShare $share
Expand Down Expand Up @@ -387,6 +378,30 @@ public function move(IShare $share, $recipient): IShare {
}


/**
* @param IShare $share
* @param string $recipient
*
* @return IShare
*/
public function restore(IShare $share, string $recipient): IShare {
$orig = $this->shareWrapperService->getShareById((int)$share->getId());

$federatedUser = $this->federatedUserService->getLocalFederatedUser($recipient);
$child = $this->shareWrapperService->getChild($share, $federatedUser);
$this->debug('Shares::restore()', ['federatedUser' => $federatedUser, 'child' => $child]);

if ($child->getPermissions() !== $orig->getPermissions()) {
$child->setPermissions($orig->getPermissions());
$this->shareWrapperService->update($child);
}

$wrappedShare = $this->shareWrapperService->getShareById((int)$share->getId(), $federatedUser);

return $wrappedShare->getShare($this->rootFolder, $this->userManager, $this->urlGenerator);
}


/**
* @param string $userId
* @param Folder $node
Expand Down Expand Up @@ -609,6 +624,22 @@ public function getShareByToken($token): IShare {
}


public function formatShare(IShare $share): array {
$this->federatedUserService->initCurrentUser();
$circleProbe = new CircleProbe();
$dataProbe = new DataProbe();

$result = ['share_with' => $share->getSharedWith()];
try {
$circle = $this->circleService->probeCircle($share->getSharedWith(), $circleProbe, $dataProbe);
$result['share_with_displayname'] = $circle->getDisplayName();
} catch (Exception $e) {
}

return $result;
}


/**
* @param string $uid
* @param int $shareType
Expand Down