aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/models/Share.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/src/models/Share.ts')
-rw-r--r--apps/files_sharing/src/models/Share.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/apps/files_sharing/src/models/Share.ts b/apps/files_sharing/src/models/Share.ts
index 28631dc7288..b0638b29448 100644
--- a/apps/files_sharing/src/models/Share.ts
+++ b/apps/files_sharing/src/models/Share.ts
@@ -21,6 +21,10 @@ export default class Share {
ocsData = ocsData.ocs.data[0]
}
+ // string to int
+ if (typeof ocsData.id === 'string') {
+ ocsData.id = Number.parseInt(ocsData.id)
+ }
// convert int into boolean
ocsData.hide_download = !!ocsData.hide_download
ocsData.mail_send = !!ocsData.mail_send
@@ -77,7 +81,7 @@ export default class Share {
* Get the share attributes
*/
get attributes(): Array<ShareAttribute> {
- return this._share.attributes
+ return this._share.attributes || []
}
/**
@@ -241,12 +245,22 @@ export default class Share {
*/
get hideDownload(): boolean {
return this._share.hide_download === true
+ || this.attributes.find?.(({ scope, key, value }) => scope === 'permissions' && key === 'download' && !value) !== undefined
}
/**
* Hide the download button on public page
*/
set hideDownload(state: boolean) {
+ // disabling hide-download also enables the download permission
+ // needed for regression in Nextcloud 31.0.0 until (incl.) 31.0.3
+ if (!state) {
+ const attribute = this.attributes.find(({ key, scope }) => key === 'download' && scope === 'permissions')
+ if (attribute) {
+ attribute.value = true
+ }
+ }
+
this._share.hide_download = state === true
}
@@ -472,4 +486,11 @@ export default class Share {
return this._share.status
}
+ /**
+ * Is the share from a trusted server
+ */
+ get isTrustedServer(): boolean {
+ return !!this._share.is_trusted_server
+ }
+
}