From a74991bd2d1245e69ee8b005e54b5922bfc4436c Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 28 Jul 2026 09:55:38 +0200 Subject: [PATCH] feat(Sharing): Add hint for enforced expiration date Signed-off-by: provokateurin --- .../Property/ExpirationDateSharePropertyType.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/Sharing/Property/ExpirationDateSharePropertyType.php b/core/Sharing/Property/ExpirationDateSharePropertyType.php index 0015c764f84..0bd213c6075 100644 --- a/core/Sharing/Property/ExpirationDateSharePropertyType.php +++ b/core/Sharing/Property/ExpirationDateSharePropertyType.php @@ -40,6 +40,10 @@ final class ExpirationDateSharePropertyType extends ADateSharePropertyType imple #[\Override] public function getHint(IFactory $l10nFactory, Share $share): ?string { + if ($this->isRequired($share)) { + return $l10nFactory->get(Application::APP_ID)->t('Your administrator has enforced a %d days expiration policy.', [$this->getMaxExpirationDays($share)]); + } + return null; } @@ -62,6 +66,7 @@ final class ExpirationDateSharePropertyType extends ADateSharePropertyType imple if ($this->hasRemoteRecipient($share) && $this->legacyManager->shareApiRemoteDefaultExpireDateEnforced()) { return true; } + return $this->hasLocalNonTokenAndEmailRecipient($share) && $this->legacyManager->shareApiInternalDefaultExpireDateEnforced(); } @@ -86,7 +91,7 @@ final class ExpirationDateSharePropertyType extends ADateSharePropertyType imple return null; } - private function getMaxExpirationDate(Share $share): ?DateTimeImmutable { + private function getMaxExpirationDays(Share $share): ?int { $days = INF; if ($this->hasTokenOrEmailRecipient($share) && $this->legacyManager->shareApiLinkDefaultExpireDate()) { @@ -102,6 +107,15 @@ final class ExpirationDateSharePropertyType extends ADateSharePropertyType imple } if ($days !== INF) { + return $days; + } + + return null; + } + + private function getMaxExpirationDate(Share $share): ?DateTimeImmutable { + $days = $this->getMaxExpirationDays($share); + if ($days !== null) { return $this->now->add(new DateInterval('P' . $days . 'D')); }