Gracefully handle not found card for a share

Fixes: #3464
Fixes: #4565

Signed-off-by: Jonas <jonas@freesources.org>
This commit is contained in:
Jonas
2023-03-28 16:40:20 +02:00
committed by backportbot-nextcloud[bot]
parent ea592251f9
commit 99260ae966

View File

@@ -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();