diff options
-rw-r--r-- | apps/files_sharing/lib/Controller/DeletedShareAPIController.php | 12 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 19 | ||||
-rw-r--r-- | lib/public/Share/IManager.php | 14 |
3 files changed, 34 insertions, 11 deletions
diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php index 9dadf8e25b4..2e4f4d52d74 100644 --- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php +++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php @@ -73,17 +73,7 @@ class DeletedShareAPIController extends OCSController { * @NoAdminRequired */ public function index(): DataResponse { - $shares = $this->shareManager->getSharedWith($this->userId, \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0); - - // Only get deleted shares - $shares = array_filter($shares, function(IShare $share) { - return $share->getPermissions() === 0; - }); - - // Only get shares where the owner still exists - $shares = array_filter($shares, function (IShare $share) { - return $this->userManager->userExists($share->getShareOwner()); - }); + $shares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0); $shares = array_map(function (IShare $share) { return $this->formatShare($share); diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index c0827f13732..5116351a6bc 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1132,6 +1132,25 @@ class Manager implements IManager { /** * @inheritdoc */ + public function getDeletedSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0) { + $shares = $this->getSharedWith($userId, $shareType, $node, $limit, $offset); + + // Only get deleted shares + $shares = array_filter($shares, function(IShare $share) { + return $share->getPermissions() === 0; + }); + + // Only get shares where the owner still exists + $shares = array_filter($shares, function (IShare $share) { + return $this->userManager->userExists($share->getShareOwner()); + }); + + return $shares; + } + + /** + * @inheritdoc + */ public function getShareById($id, $recipient = null) { if ($id === null) { throw new ShareNotFound(); diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 56e35f517c1..c8abab378ec 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -150,6 +150,20 @@ interface IManager { public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0); /** + * Get deleted shares shared with $user. + * Filter by $node if provided + * + * @param string $userId + * @param int $shareType + * @param Node|null $node + * @param int $limit The maximum number of shares returned, -1 for all + * @param int $offset + * @return IShare[] + * @since 9.0.0 + */ + public function getDeletedSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0); + + /** * Retrieve a share by the share id. * If the recipient is set make sure to retrieve the file for that user. * This makes sure that if a user has moved/deleted a group share this |