mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
fix(sharing): Use link_defaultExpDays for default expiration in web UI
The link_defaultExpDays config was only used in the backend share validation but never exposed to the frontend, making it impossible to set a default expiration date different from the maximum.
This commit is contained in:
parent
7ed3134160
commit
8d707a1e5b
2 changed files with 20 additions and 4 deletions
|
|
@ -123,7 +123,13 @@ class Capabilities implements ICapability {
|
|||
$public['multiple_links'] = true;
|
||||
$public['expire_date']['enabled'] = $this->shareManager->shareApiLinkDefaultExpireDate();
|
||||
if ($public['expire_date']['enabled']) {
|
||||
$public['expire_date']['days'] = $this->shareManager->shareApiLinkDefaultExpireDays();
|
||||
$maxDays = $this->shareManager->shareApiLinkDefaultExpireDays();
|
||||
$defaultDays = (int)$this->config->getAppValue('core', 'link_defaultExpDays', (string)$maxDays);
|
||||
if ($defaultDays > $maxDays) {
|
||||
$defaultDays = $maxDays;
|
||||
}
|
||||
$public['expire_date']['days'] = $maxDays;
|
||||
$public['expire_date']['default_days'] = $defaultDays;
|
||||
$public['expire_date']['enforced'] = $this->shareManager->shareApiLinkDefaultExpireDateEnforced();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,8 +130,11 @@ export default class Config {
|
|||
* Get the default link share expiration date
|
||||
*/
|
||||
get defaultExpirationDate(): Date | null {
|
||||
if (this.isDefaultExpireDateEnabled && this.defaultExpireDate !== null) {
|
||||
return new Date(new Date().setDate(new Date().getDate() + this.defaultExpireDate))
|
||||
if (this.isDefaultExpireDateEnabled) {
|
||||
const days = this.linkDefaultExpDays ?? this.defaultExpireDate
|
||||
if (days !== null) {
|
||||
return new Date(new Date().setDate(new Date().getDate() + days))
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
|
@ -243,12 +246,19 @@ export default class Config {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the default days to link shares expiration
|
||||
* Get the maximum days to link shares expiration
|
||||
*/
|
||||
get defaultExpireDate(): number | null {
|
||||
return window.OC.appConfig.core.defaultExpireDate
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default days to link shares expiration
|
||||
*/
|
||||
get linkDefaultExpDays(): number | null {
|
||||
return this._capabilities?.files_sharing?.public?.expire_date?.default_days ?? null
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default days to internal shares expiration
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue