aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorfenn-cs <fenn25.fn@gmail.com>2024-04-15 21:38:55 +0100
committerfenn-cs <fenn25.fn@gmail.com>2024-04-18 02:01:13 +0100
commitec8a0a6267d7a410caa40d39f30e529d62a9a0dc (patch)
tree6f56d77ba8539a2aca62a24eecac8246f8468f44 /apps/files_sharing/lib
parent9a0913afdc7c545b142c8919f24e41798b388a2c (diff)
downloadnextcloud-server-ec8a0a6267d7a410caa40d39f30e529d62a9a0dc.tar.gz
nextcloud-server-ec8a0a6267d7a410caa40d39f30e529d62a9a0dc.zip
fix(shareApiController): avoid duplicated expiryDate operations
`expireDate` can be set once and used anywhere needed, the current implementation, duplicates this behavior which leads to `parseDate` receiving an a date object it parsed and returend earlier in the createShare method. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php37
1 files changed, 10 insertions, 27 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 4aa723783db..fa0e2d56007 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -645,6 +645,16 @@ class ShareAPIController extends OCSController {
$share = $this->setShareAttributes($share, $attributes);
}
+ //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->setSharedBy($this->currentUser);
$this->checkInheritedAttributes($share);
@@ -731,15 +741,6 @@ class ShareAPIController extends OCSController {
$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'));
- }
- }
-
$share->setSharedWithDisplayName($this->getCachedFederatedDisplayName($shareWith, false));
} elseif ($shareType === IShare::TYPE_REMOTE_GROUP) {
if (!$this->shareManager->outgoingServer2ServerGroupSharesAllowed()) {
@@ -752,14 +753,6 @@ class ShareAPIController extends OCSController {
$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'));
@@ -795,16 +788,6 @@ 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 !== '') {