fix(sharing): Separate max and default expiration dates in link share UI

The maxExpirationDateEnforced was using defaultExpirationDate which
now returns the default date (linkDefaultExpDays) instead of the
maximum (shareapi_expire_after_n_days), preventing users from picking
dates between the default and maximum.

Signed-off-by: nfebe <fenn25.fn@gmail.com>
This commit is contained in:
nfebe 2026-02-24 16:44:00 +01:00
parent a7dd7a9c66
commit f1ff7d7142
7 changed files with 45 additions and 2 deletions

View file

@ -46,6 +46,7 @@ class Capabilities implements ICapability {
* expire_date?: array{
* enabled: bool,
* days?: int,
* default_days?: int,
* enforced?: bool,
* },
* expire_date_internal?: array{

View file

@ -80,6 +80,10 @@
"type": "integer",
"format": "int64"
},
"default_days": {
"type": "integer",
"format": "int64"
},
"enforced": {
"type": "boolean"
}

View file

@ -151,7 +151,7 @@ export default {
maxExpirationDateEnforced() {
if (this.isExpiryDateEnforced) {
if (this.isPublicShare) {
return this.config.defaultExpirationDate
return this.config.maxExpirationDate
}
if (this.isRemoteShare) {
return this.config.defaultRemoteExpirationDateString

View file

@ -24,6 +24,7 @@ type FileSharingCapabilities = {
expire_date: {
enabled: boolean
days: number
default_days: number
enforced: boolean
}
multiple_links: boolean
@ -139,6 +140,16 @@ export default class Config {
return null
}
/**
* Get the maximum link share expiration date
*/
get maxExpirationDate(): Date | null {
if (this.isDefaultExpireDateEnabled && this.defaultExpireDate !== null) {
return new Date(new Date().setDate(new Date().getDate() + this.defaultExpireDate))
}
return null
}
/**
* Get the default internal expiration date
*/

View file

@ -188,6 +188,7 @@ class CapabilitiesTest extends \Test\TestCase {
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '7'],
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
['core', 'link_defaultExpDays', '7', '7'],
];
$typedMap = [
@ -199,7 +200,28 @@ class CapabilitiesTest extends \Test\TestCase {
$this->assertArrayHasKey('expire_date', $result['public']);
$this->assertIsArray($result['public']['expire_date']);
$this->assertTrue($result['public']['expire_date']['enabled']);
$this->assertArrayHasKey('days', $result['public']['expire_date']);
$this->assertSame(7, $result['public']['expire_date']['days']);
$this->assertSame(7, $result['public']['expire_date']['default_days']);
$this->assertFalse($result['public']['expire_date']['enforced']);
}
public function testLinkExpireDateWithDefaultDays(): void {
$map = [
['core', 'shareapi_enabled', 'yes', 'yes'],
['core', 'shareapi_allow_links', 'yes', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '7'],
['core', 'shareapi_enforce_links_password_excluded_groups', '', ''],
['core', 'link_defaultExpDays', '7', '3'],
];
$typedMap = [
['core', 'shareapi_default_expire_date', true],
['core', 'shareapi_enforce_expire_date', false],
];
$result = $this->getResults($map, $typedMap);
$this->assertSame(7, $result['public']['expire_date']['days']);
$this->assertSame(3, $result['public']['expire_date']['default_days']);
$this->assertFalse($result['public']['expire_date']['enforced']);
}

View file

@ -1466,6 +1466,7 @@
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[getAppValue]]></code>
</DeprecatedMethod>
</file>
<file src="apps/files_sharing/lib/Controller/DeletedShareAPIController.php">

View file

@ -2223,6 +2223,10 @@
"type": "integer",
"format": "int64"
},
"default_days": {
"type": "integer",
"format": "int64"
},
"enforced": {
"type": "boolean"
}