Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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 <[email protected]>
  • Loading branch information
rullzer committed Jan 7, 2020
commit fbed6a3416dd96e3698575f67dc57fc861c2ed46
5 changes: 5 additions & 0 deletions apps/files_sharing/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
'url' => '/api/v1/shares',
'verb' => 'POST',
],
[
'name' => 'ShareAPI#pendingShares',
'url' => '/api/v1/shares/pending',
'verb' => 'GET',
],
[
'name' => 'ShareAPI#getShare',
'url' => '/api/v1/shares/{id}',
Expand Down
30 changes: 30 additions & 0 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,36 @@ public function updateShare(
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
*
Expand Down