mirror of
https://github.com/nextcloud/server.git
synced 2026-04-29 18:11:41 -04:00
Merge pull request #48937 from nextcloud/backport/48918/stable30
This commit is contained in:
commit
8eaf664fa6
3 changed files with 12 additions and 12 deletions
|
|
@ -158,7 +158,7 @@ class ShareAPIController extends OCSController {
|
|||
if ($isOwnShare) {
|
||||
$result['item_permissions'] = $node->getPermissions();
|
||||
}
|
||||
|
||||
|
||||
// If we're on the recipient side, the node permissions
|
||||
// are bound to the share permissions. So we need to
|
||||
// adjust the permissions to the share permissions if necessary.
|
||||
|
|
@ -645,7 +645,7 @@ class ShareAPIController extends OCSController {
|
|||
$expireDateTime = $this->parseDate($expireDate);
|
||||
$share->setExpirationDate($expireDateTime);
|
||||
} catch (\Exception $e) {
|
||||
throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
|
||||
throw new OCSNotFoundException($e->getMessage(), $e);
|
||||
}
|
||||
} else {
|
||||
// Client sent empty string for expire date.
|
||||
|
|
@ -811,12 +811,11 @@ class ShareAPIController extends OCSController {
|
|||
try {
|
||||
$share = $this->shareManager->createShare($share);
|
||||
} catch (GenericShareException $e) {
|
||||
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||
$code = $e->getCode() === 0 ? 403 : $e->getCode();
|
||||
throw new OCSException($e->getHint(), $code);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||
throw new OCSForbiddenException($e->getMessage(), $e);
|
||||
throw new OCSForbiddenException('Failed to create share.', $e);
|
||||
}
|
||||
|
||||
$output = $this->formatShare($share);
|
||||
|
|
@ -1343,11 +1342,11 @@ class ShareAPIController extends OCSController {
|
|||
$share->setExpirationDate(null);
|
||||
} elseif ($expireDate !== null) {
|
||||
try {
|
||||
$expireDate = $this->parseDate($expireDate);
|
||||
$expireDateTime = $this->parseDate($expireDate);
|
||||
$share->setExpirationDate($expireDateTime);
|
||||
} catch (\Exception $e) {
|
||||
throw new OCSBadRequestException($e->getMessage(), $e);
|
||||
}
|
||||
$share->setExpirationDate($expireDate);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -1356,7 +1355,8 @@ class ShareAPIController extends OCSController {
|
|||
$code = $e->getCode() === 0 ? 403 : $e->getCode();
|
||||
throw new OCSException($e->getHint(), (int)$code);
|
||||
} catch (\Exception $e) {
|
||||
throw new OCSBadRequestException($e->getMessage(), $e);
|
||||
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||
throw new OCSBadRequestException('Failed to update share.', $e);
|
||||
}
|
||||
|
||||
return new DataResponse($this->formatShare($share));
|
||||
|
|
@ -1443,7 +1443,8 @@ class ShareAPIController extends OCSController {
|
|||
$code = $e->getCode() === 0 ? 403 : $e->getCode();
|
||||
throw new OCSException($e->getHint(), (int)$code);
|
||||
} catch (\Exception $e) {
|
||||
throw new OCSBadRequestException($e->getMessage(), $e);
|
||||
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||
throw new OCSBadRequestException('Failed to accept share.', $e);
|
||||
}
|
||||
|
||||
return new DataResponse();
|
||||
|
|
@ -2134,9 +2135,8 @@ class ShareAPIController extends OCSController {
|
|||
|
||||
$provider->sendMailNotification($share);
|
||||
return new DataResponse();
|
||||
} catch(OCSBadRequestException $e) {
|
||||
throw $e;
|
||||
} catch (Exception $e) {
|
||||
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||
throw new OCSException($this->l->t('Error while sending mail notification'));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1294,7 +1294,7 @@ class ApiTest extends TestCase {
|
|||
$this->assertTrue($valid);
|
||||
} catch (OCSNotFoundException $e) {
|
||||
$this->assertFalse($valid);
|
||||
$this->assertEquals('Invalid date, date format must be YYYY-MM-DD', $e->getMessage());
|
||||
$this->assertEquals('Invalid date. Format must be YYYY-MM-DD', $e->getMessage());
|
||||
$ocs->cleanup();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2212,7 +2212,7 @@ class ShareAPIControllerTest extends TestCase {
|
|||
|
||||
public function testCreateShareInvalidExpireDate() {
|
||||
$this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
|
||||
$this->expectExceptionMessage('Invalid date, date format must be YYYY-MM-DD');
|
||||
$this->expectExceptionMessage('Invalid date. Format must be YYYY-MM-DD');
|
||||
|
||||
$ocs = $this->mockFormatShare();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue