diff --git a/lib/ShareByCircleProvider.php b/lib/ShareByCircleProvider.php index ff80f7b10..501c9cf65 100644 --- a/lib/ShareByCircleProvider.php +++ b/lib/ShareByCircleProvider.php @@ -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 @@ -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 @@ -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