From 594baac8b45e3c45082090d3008a467d87655ad0 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 30 Nov 2022 09:56:06 -0100 Subject: [PATCH] deleted circles shares Signed-off-by: Maxence Lange --- .../Controller/DeletedShareAPIController.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php index 1d625b35322a1..76e742058d556 100644 --- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php +++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php @@ -159,6 +159,11 @@ private function formatShare(IShare $share): array { $result = array_merge($result, $this->getDeckShareHelper()->formatShare($share)); } catch (QueryException $e) { } + } elseif ($share->getShareType() === IShare::TYPE_CIRCLE) { + try { + $result = array_merge($result, $this->getCirclesShareHelper()->formatShare($share)); + } catch (QueryException $e) { + } } return $result; @@ -171,8 +176,9 @@ public function index(): DataResponse { $groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0); $roomShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_ROOM, null, -1, 0); $deckShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_DECK, null, -1, 0); + $circlesShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_CIRCLE, null, -1, 0); - $shares = array_merge($groupShares, $roomShares, $deckShares); + $shares = array_merge($groupShares, $roomShares, $deckShares, $circlesShares); $shares = array_map(function (IShare $share) { return $this->formatShare($share); @@ -239,4 +245,21 @@ private function getDeckShareHelper() { return $this->serverContainer->get('\OCA\Deck\Sharing\ShareAPIHelper'); } + + /** + * Returns the helper of ShareAPIHelper for circles shares. + * + * If the Circles application is not enabled or the helper is not available + * a QueryException is thrown instead. + * + * @return \OCA\Circles\ShareAPIHelper + * @throws QueryException + */ + private function getCirclesShareHelper() { + if (!$this->appManager->isEnabledForUser('circles')) { + throw new QueryException(); + } + + return $this->serverContainer->get('\OCA\Circles\ShareByCircleProvider'); + } }