diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-08-01 09:44:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-01 09:44:31 +0200 |
commit | f74e89bde5892a68500eeea3fa98a511b1d7f7e9 (patch) | |
tree | a152cdabfedf9caf21483b5dfb9e3f2574cc3ca5 /core | |
parent | 952acd4d276b3190d23e0597c5e01b1dfc4d72bc (diff) | |
parent | 7b723813cef60e744ab14ab418c82e5ec67a9f2e (diff) | |
download | nextcloud-server-f74e89bde5892a68500eeea3fa98a511b1d7f7e9.tar.gz nextcloud-server-f74e89bde5892a68500eeea3fa98a511b1d7f7e9.zip |
Merge pull request #32482 from nextcloud/enh/noid/share-attributes
Add share attributes + prevent download permission
Diffstat (limited to 'core')
-rw-r--r-- | core/src/files/client.js | 17 | ||||
-rw-r--r-- | core/src/files/fileinfo.js | 16 |
2 files changed, 33 insertions, 0 deletions
diff --git a/core/src/files/client.js b/core/src/files/client.js index 630e9fb98ad..2c71fbe46e1 100644 --- a/core/src/files/client.js +++ b/core/src/files/client.js @@ -104,6 +104,7 @@ import escapeHTML from 'escape-html' Client.PROPERTY_GETCONTENTLENGTH = '{' + Client.NS_DAV + '}getcontentlength' Client.PROPERTY_ISENCRYPTED = '{' + Client.NS_DAV + '}is-encrypted' Client.PROPERTY_SHARE_PERMISSIONS = '{' + Client.NS_OCS + '}share-permissions' + Client.PROPERTY_SHARE_ATTRIBUTES = '{' + Client.NS_NEXTCLOUD + '}share-attributes' Client.PROPERTY_QUOTA_AVAILABLE_BYTES = '{' + Client.NS_DAV + '}quota-available-bytes' Client.PROTOCOL_HTTP = 'http' @@ -160,6 +161,10 @@ import escapeHTML from 'escape-html' * Share permissions */ [Client.NS_OCS, 'share-permissions'], + /** + * Share attributes + */ + [Client.NS_NEXTCLOUD, 'share-attributes'], ] /** @@ -416,6 +421,18 @@ import escapeHTML from 'escape-html' data.sharePermissions = parseInt(sharePermissionsProp) } + const shareAttributesProp = props[Client.PROPERTY_SHARE_ATTRIBUTES] + if (!_.isUndefined(shareAttributesProp)) { + try { + data.shareAttributes = JSON.parse(shareAttributesProp) + } catch (e) { + console.warn('Could not parse share attributes returned by server: "' + shareAttributesProp + '"') + data.shareAttributes = []; + } + } else { + data.shareAttributes = []; + } + const mounTypeProp = props['{' + Client.NS_NEXTCLOUD + '}mount-type'] if (!_.isUndefined(mounTypeProp)) { data.mountType = mounTypeProp diff --git a/core/src/files/fileinfo.js b/core/src/files/fileinfo.js index ea49e8c1447..3fe90f82ac9 100644 --- a/core/src/files/fileinfo.js +++ b/core/src/files/fileinfo.js @@ -155,7 +155,23 @@ */ sharePermissions: null, + /** + * @type Array + */ + shareAttributes: [], + quotaAvailableBytes: -1, + + canDownload: function() { + for (const i in this.shareAttributes) { + const attr = this.shareAttributes[i] + if (attr.scope === 'permissions' && attr.key === 'download') { + return attr.enabled + } + } + + return true + }, } if (!OC.Files) { |