aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-04-15 12:06:54 -0100
committerGitHub <noreply@github.com>2021-04-15 12:06:54 -0100
commit1c35b3801e49eb9011040a23e64d787172fa562e (patch)
tree9b608272439503e0015ece40ae4b77013eabc81f /apps/files_sharing/lib
parent8ef920fdf90bc54d6f17134ebd80a71db2f9d8ea (diff)
parentaf61486aea90cfc1a82301ce624dffb59ed01e07 (diff)
downloadnextcloud-server-1c35b3801e49eb9011040a23e64d787172fa562e.tar.gz
nextcloud-server-1c35b3801e49eb9011040a23e64d787172fa562e.zip
Merge pull request #25320 from nextcloud/bugfix/noid/save-fed-share-expiration
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/Capabilities.php12
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php24
2 files changed, 35 insertions, 1 deletions
diff --git a/apps/files_sharing/lib/Capabilities.php b/apps/files_sharing/lib/Capabilities.php
index 88af806b2f9..5a0b9d7e71d 100644
--- a/apps/files_sharing/lib/Capabilities.php
+++ b/apps/files_sharing/lib/Capabilities.php
@@ -86,6 +86,13 @@ class Capabilities implements ICapability {
$public['expire_date_internal']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no') === 'yes';
}
+ $public['expire_date_remote'] = [];
+ $public['expire_date_remote']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_remote_expire_date', 'no') === 'yes';
+ if ($public['expire_date_remote']['enabled']) {
+ $public['expire_date_remote']['days'] = $this->config->getAppValue('core', 'shareapi_remote_expire_after_n_days', '7');
+ $public['expire_date_remote']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_remote_expire_date', 'no') === 'yes';
+ }
+
$public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no') === 'yes';
$public['upload'] = $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes';
$public['upload_files_drop'] = $public['upload'];
@@ -111,7 +118,10 @@ class Capabilities implements ICapability {
$res['federation'] = [
'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes',
'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes',
- 'expire_date' => ['enabled' => true]
+ // old bogus one, expire_date was not working before, keeping for compatibility
+ 'expire_date' => ['enabled' => true],
+ // the real deal, signifies that expiration date can be set on federated shares
+ 'expire_date_supported' => ['enabled' => true],
];
// Sharee searches
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 922623aa46f..f3b0467fa14 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -587,15 +587,39 @@ class ShareAPIController extends OCSController {
throw new OCSForbiddenException($this->l->t('Sharing %1$s failed because the back end does not allow shares from type %2$s', [$path->getPath(), $shareType]));
}
+ if ($shareWith === null) {
+ throw new OCSNotFoundException($this->l->t('Please specify a valid federated user id'));
+ }
+
$share->setSharedWith($shareWith);
$share->setPermissions($permissions);
+ if ($expireDate !== '') {
+ try {
+ $expireDate = $this->parseDate($expireDate);
+ $share->setExpirationDate($expireDate);
+ } catch (\Exception $e) {
+ throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
+ }
+ }
} elseif ($shareType === IShare::TYPE_REMOTE_GROUP) {
if (!$this->shareManager->outgoingServer2ServerGroupSharesAllowed()) {
throw new OCSForbiddenException($this->l->t('Sharing %1$s failed because the back end does not allow shares from type %2$s', [$path->getPath(), $shareType]));
}
+ if ($shareWith === null) {
+ throw new OCSNotFoundException($this->l->t('Please specify a valid federated group id'));
+ }
+
$share->setSharedWith($shareWith);
$share->setPermissions($permissions);
+ if ($expireDate !== '') {
+ try {
+ $expireDate = $this->parseDate($expireDate);
+ $share->setExpirationDate($expireDate);
+ } catch (\Exception $e) {
+ throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
+ }
+ }
} elseif ($shareType === IShare::TYPE_CIRCLE) {
if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) {
throw new OCSNotFoundException($this->l->t('You cannot share to a Circle if the app is not enabled'));