From 99260ae96638cebb91e04ec15a5f8f70f420865e Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 28 Mar 2023 16:40:20 +0200 Subject: [PATCH] Gracefully handle not found card for a share Fixes: #3464 Fixes: #4565 Signed-off-by: Jonas --- lib/Sharing/ShareAPIHelper.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Sharing/ShareAPIHelper.php b/lib/Sharing/ShareAPIHelper.php index d086f2fdd..5528b6a92 100644 --- a/lib/Sharing/ShareAPIHelper.php +++ b/lib/Sharing/ShareAPIHelper.php @@ -30,8 +30,10 @@ use OCA\Deck\Db\Acl; use OCA\Deck\Db\CardMapper; use OCA\Deck\NoPermissionException; use OCA\Deck\Service\PermissionService; +use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Files\NotFoundException; use OCP\IL10N; use OCP\IURLGenerator; use OCP\Share\IShare; @@ -53,7 +55,11 @@ class ShareAPIHelper { public function formatShare(IShare $share): array { $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()); $result['share_with'] = $share->getSharedWith(); $result['share_with_displayname'] = $card->getTitle();