Merge pull request #4568 from nextcloud/backport/4566/stable25

[stable25] Gracefully handle not found card for a share
This commit is contained in:
Jonas
2023-03-29 11:13:24 +02:00
committed by GitHub

View File

@@ -30,8 +30,10 @@ use OCA\Deck\Db\Acl;
use OCA\Deck\Db\CardMapper; use OCA\Deck\Db\CardMapper;
use OCA\Deck\NoPermissionException; use OCA\Deck\NoPermissionException;
use OCA\Deck\Service\PermissionService; use OCA\Deck\Service\PermissionService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\Utility\ITimeFactory; use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\NotFoundException;
use OCP\IL10N; use OCP\IL10N;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\Share\IShare; use OCP\Share\IShare;
@@ -53,7 +55,11 @@ class ShareAPIHelper {
public function formatShare(IShare $share): array { public function formatShare(IShare $share): array {
$result = []; $result = [];
$card = $this->cardMapper->find($share->getSharedWith()); try {
$card = $this->cardMapper->find($share->getSharedWith());
} catch (DoesNotExistException $e) {
throw new NotFoundException($e->getMessage());
}
$boardId = $this->cardMapper->findBoardId($card->getId()); $boardId = $this->cardMapper->findBoardId($card->getId());
$result['share_with'] = $share->getSharedWith(); $result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = $card->getTitle(); $result['share_with_displayname'] = $card->getTitle();