aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2023-04-27 16:26:24 +0200
committerLouis Chemineau <louis@chmn.me>2023-04-27 16:26:24 +0200
commit6b53e4b13a909f4d7fe3bf239450a1285ed62d6c (patch)
tree04b155b7e40b77eb8ac8ac7429d6f165843be5e0 /apps/files_sharing/lib
parentda274d18ffd06ac102fe61c0d464291b43f30e5a (diff)
downloadnextcloud-server-6b53e4b13a909f4d7fe3bf239450a1285ed62d6c.tar.gz
nextcloud-server-6b53e4b13a909f4d7fe3bf239450a1285ed62d6c.zip
Mutualize expireDate handling when creating and updating a share
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php49
1 files changed, 19 insertions, 30 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index e1595a98ea3..3287d9447d8 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -627,16 +627,6 @@ class ShareAPIController extends OCSController {
$share->setSendPasswordByTalk(true);
}
-
- //Expire date
- 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) {
if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
throw new OCSForbiddenException($this->l->t('Sharing %1$s failed because the back end does not allow shares from type %2$s', [$node->getPath(), $shareType]));
@@ -710,6 +700,16 @@ class ShareAPIController extends OCSController {
throw new OCSBadRequestException($this->l->t('Unknown share type'));
}
+ //Expire date
+ 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'));
+ }
+ }
+
$share->setShareType($shareType);
if ($note !== '') {
@@ -1216,17 +1216,6 @@ class ShareAPIController extends OCSController {
$permissions = $newPermissions;
}
- if ($expireDate === '') {
- $share->setExpirationDate(null);
- } elseif ($expireDate !== null) {
- try {
- $expireDate = $this->parseDate($expireDate);
- } catch (\Exception $e) {
- throw new OCSBadRequestException($e->getMessage(), $e);
- }
- $share->setExpirationDate($expireDate);
- }
-
if ($password === '') {
$share->setPassword(null);
} elseif ($password !== null) {
@@ -1256,17 +1245,17 @@ class ShareAPIController extends OCSController {
if ($permissions !== null) {
$share->setPermissions($permissions);
}
+ }
- if ($expireDate === '') {
- $share->setExpirationDate(null);
- } elseif ($expireDate !== null) {
- try {
- $expireDate = $this->parseDate($expireDate);
- } catch (\Exception $e) {
- throw new OCSBadRequestException($e->getMessage(), $e);
- }
- $share->setExpirationDate($expireDate);
+ if ($expireDate === '') {
+ $share->setExpirationDate(null);
+ } elseif ($expireDate !== null) {
+ try {
+ $expireDate = $this->parseDate($expireDate);
+ } catch (\Exception $e) {
+ throw new OCSBadRequestException($e->getMessage(), $e);
}
+ $share->setExpirationDate($expireDate);
}
try {