@@ -307,15 +307,6 @@ public function deleteFromSelf(IShare $share, $recipient): void {
307307 }
308308 }
309309
310- /**
311- * @param IShare $share
312- * @param string $recipient
313- *
314- * @return IShare
315- */
316- public function restore (IShare $ share , string $ recipient ): IShare {
317- return $ share ;
318- }
319310
320311 /**
321312 * @param IShare $share
@@ -350,6 +341,30 @@ public function move(IShare $share, $recipient): IShare {
350341 }
351342
352343
344+ /**
345+ * @param IShare $share
346+ * @param string $recipient
347+ *
348+ * @return IShare
349+ */
350+ public function restore (IShare $ share , string $ recipient ): IShare {
351+ $ orig = $ this ->shareWrapperService ->getShareById ((int )$ share ->getId ());
352+
353+ $ federatedUser = $ this ->federatedUserService ->getLocalFederatedUser ($ recipient );
354+ $ child = $ this ->shareWrapperService ->getChild ($ share , $ federatedUser );
355+ $ this ->debug ('Shares::restore() ' , ['federatedUser ' => $ federatedUser , 'child ' => $ child ]);
356+
357+ if ($ child ->getPermissions () !== $ orig ->getPermissions ()) {
358+ $ child ->setPermissions ($ orig ->getPermissions ());
359+ $ this ->shareWrapperService ->update ($ child );
360+ }
361+
362+ $ wrappedShare = $ this ->shareWrapperService ->getShareById ((int )$ share ->getId (), $ federatedUser );
363+
364+ return $ wrappedShare ->getShare ($ this ->rootFolder , $ this ->userManager , $ this ->urlGenerator );
365+ }
366+
367+
353368 /**
354369 * @param string $userId
355370 * @param Folder $node
@@ -579,6 +594,22 @@ public function getShareByToken($token): IShare {
579594 }
580595
581596
597+ public function formatShare (IShare $ share ): array {
598+ $ this ->federatedUserService ->initCurrentUser ();
599+ $ circleProbe = new CircleProbe ();
600+ $ dataProbe = new DataProbe ();
601+
602+ $ result = ['share_with ' => $ share ->getSharedWith ()];
603+ try {
604+ $ circle = $ this ->circleService ->probeCircle ($ share ->getSharedWith (), $ circleProbe , $ dataProbe );
605+ $ result ['share_with_displayname ' ] = $ circle ->getDisplayName ();
606+ } catch (Exception $ e ) {
607+ }
608+
609+ return $ result ;
610+ }
611+
612+
582613 /**
583614 * @param string $uid
584615 * @param int $shareType
0 commit comments