From fbed6a3416dd96e3698575f67dc57fc861c2ed46 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 7 Jan 2020 08:53:33 +0100 Subject: A pending shares overview Now that we accept shares we should show an overview of shares that are pending. This first part is the small API to get a list of the currently pending shares. Signed-off-by: Roeland Jago Douma --- .../lib/Controller/ShareAPIController.php | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'apps/files_sharing/lib/Controller') diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 906eb82221b..e7c9a414958 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1079,6 +1079,36 @@ class ShareAPIController extends OCSController { return new DataResponse($this->formatShare($share)); } + /** + * @NoAdminRequired + */ + public function pendingShares(): DataResponse { + $pendingShares = []; + + $shareTypes = [ + IShare::TYPE_USER, + IShare::TYPE_GROUP + ]; + + foreach ($shareTypes as $shareType) { + $shares = $this->shareManager->getSharedWith($this->currentUser, $shareType, null, -1, 0); + + foreach ($shares as $share) { + if ($share->getStatus() === IShare::STATUS_PENDING || $share->getStatus() === IShare::STATUS_REJECTED) { + $pendingShares[] = $share; + } + } + } + + $result = array_map(function (IShare $share) { + return [ + 'id' => $share->getFullId(), + ]; + }, $pendingShares); + + return new DataResponse($result); + } + /** * @NoAdminRequired * -- cgit v1.2.3