]> source.dussan.org Git - nextcloud-server.git/commitdiff
A pending shares overview
authorRoeland Jago Douma <roeland@famdouma.nl>
Tue, 7 Jan 2020 07:53:33 +0000 (08:53 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Tue, 7 Jan 2020 07:53:33 +0000 (08:53 +0100)
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 <roeland@famdouma.nl>
apps/files_sharing/appinfo/routes.php
apps/files_sharing/lib/Controller/ShareAPIController.php

index ad3d11fc3a165e4f11ad0cbbcb03b2daad5bec87..1346e0c68991cc48030f1aafac9e168583ffd2c6 100644 (file)
@@ -75,6 +75,11 @@ return [
                        'url'  => '/api/v1/shares',
                        'verb' => 'POST',
                ],
+               [
+                       'name' => 'ShareAPI#pendingShares',
+                       'url'  => '/api/v1/shares/pending',
+                       'verb' => 'GET',
+               ],
                [
                        'name' => 'ShareAPI#getShare',
                        'url'  => '/api/v1/shares/{id}',
index 906eb82221bf40f5c42b61c9a18e68ff86f6f98d..e7c9a414958de04a3d110c6b86ada43319732a48 100644 (file)
@@ -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
         *