summaryrefslogtreecommitdiffstats
path: root/core/js/shareitemmodel.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-07-13 15:46:02 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-08-03 10:16:28 +0200
commit0f3674a4469d894c804c68b12c88f47bc063f956 (patch)
tree2eec097b2b9c0076d2cc14a9b55613f775e904a5 /core/js/shareitemmodel.js
parent0bddaa23b098cee55b1d85f9a627a1df1c8a9410 (diff)
downloadnextcloud-server-0f3674a4469d894c804c68b12c88f47bc063f956.tar.gz
nextcloud-server-0f3674a4469d894c804c68b12c88f47bc063f956.zip
Group incoming shares for resharing in JS
Diffstat (limited to 'core/js/shareitemmodel.js')
-rw-r--r--core/js/shareitemmodel.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index 8ea0bf28b38..00c1212fa79 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -598,6 +598,33 @@
}
},
+ /**
+ * Group reshares into a single super share element.
+ * Does this by finding the most precise share and
+ * combines the permissions to be the most permissive.
+ *
+ * @param {Array} reshares
+ * @return {Object} reshare
+ */
+ _groupReshares: function(reshares) {
+ if (!reshares || !reshares.length) {
+ return false;
+ }
+
+ var superShare = reshares.shift();
+ var combinedPermissions = superShare.permissions;
+ _.each(reshares, function(reshare) {
+ // use share have higher priority than group share
+ if (reshare.share_type === OC.Share.SHARE_TYPE_USER && superShare.share_type === OC.Share.SHARE_TYPE_GROUP) {
+ superShare = reshare;
+ }
+ combinedPermissions |= reshare.permissions;
+ });
+
+ superShare.permissions = combinedPermissions;
+ return superShare;
+ },
+
fetch: function() {
var model = this;
this.trigger('request', this);
@@ -615,7 +642,7 @@
var reshare = false;
if (data2[0].ocs.data.length) {
- reshare = data2[0].ocs.data[0];
+ reshare = model._groupReshares(data2[0].ocs.data);
}
model.set(model.parse({