aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-08-19 10:53:29 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-10-25 21:41:12 +0200
commitdbb6b4cbb90c21a1256e62014849055b723a0f66 (patch)
tree8ed76cdb475aff5491bb124e5a01e988904fdb2a /apps
parent8098abee608e58dad8b73a1151233be525c25483 (diff)
downloadnextcloud-server-dbb6b4cbb90c21a1256e62014849055b723a0f66.tar.gz
nextcloud-server-dbb6b4cbb90c21a1256e62014849055b723a0f66.zip
Filter out duplicated shares before processing them
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 218d854f2f1..134ff6378e7 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -628,18 +628,26 @@ class ShareAPIController extends OCSController {
return $carry;
}, []);
+ // filter out duplicate shares
+ $known = [];
+ $shares = array_filter($shares, function($share) use (&$known) {
+ if (in_array($share->getId(), $known)) {
+ return false;
+ }
+ $known[] = $share->getId();
+ return true;
+ });
+
$formatted = $miniFormatted = [];
$resharingRight = false;
- $known = [];
foreach ($shares as $share) {
- if (in_array($share->getId(), $known) || $share->getSharedWith() === $this->currentUser) {
+ if ($share->getSharedWith() === $this->currentUser) {
continue;
}
try {
$format = $this->formatShare($share);
- $known[] = $share->getId();
$formatted[] = $format;
if ($share->getSharedBy() === $this->currentUser) {
$miniFormatted[] = $format;