Avoid blocking calendar access if something goes wrong while fetching deck entries

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2021-12-29 15:57:35 +01:00
parent 66fa241382
commit bfc8222e6f
2 changed files with 14 additions and 2 deletions

View File

@@ -37,6 +37,7 @@ use OCA\Deck\Db\StackMapper;
use OCA\Deck\Event\CardCreatedEvent; use OCA\Deck\Event\CardCreatedEvent;
use OCA\Deck\Event\CardDeletedEvent; use OCA\Deck\Event\CardDeletedEvent;
use OCA\Deck\Event\CardUpdatedEvent; use OCA\Deck\Event\CardUpdatedEvent;
use OCA\Deck\NoPermissionException;
use OCA\Deck\Notification\NotificationHelper; use OCA\Deck\Notification\NotificationHelper;
use OCA\Deck\Db\BoardMapper; use OCA\Deck\Db\BoardMapper;
use OCA\Deck\Db\LabelMapper; use OCA\Deck\Db\LabelMapper;
@@ -154,7 +155,12 @@ class CardService {
} }
public function findCalendarEntries($boardId) { public function findCalendarEntries($boardId) {
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ); try {
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
} catch (NoPermissionException $e) {
\OC::$server->getLogger()->error('Unable to check permission for a previously obtained board ' . $boardId, ['exception' => $e]);
return [];
}
$cards = $this->cardMapper->findCalendarEntries($boardId); $cards = $this->cardMapper->findCalendarEntries($boardId);
foreach ($cards as $card) { foreach ($cards as $card) {
$this->enrich($card); $this->enrich($card);

View File

@@ -35,6 +35,7 @@ use OCA\Deck\Db\ChangeHelper;
use OCA\Deck\Db\LabelMapper; use OCA\Deck\Db\LabelMapper;
use OCA\Deck\Db\Stack; use OCA\Deck\Db\Stack;
use OCA\Deck\Db\StackMapper; use OCA\Deck\Db\StackMapper;
use OCA\Deck\NoPermissionException;
use OCA\Deck\StatusException; use OCA\Deck\StatusException;
class StackService { class StackService {
@@ -142,7 +143,12 @@ class StackService {
} }
public function findCalendarEntries($boardId) { public function findCalendarEntries($boardId) {
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ); try {
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
} catch (NoPermissionException $e) {
\OC::$server->getLogger()->error('Unable to check permission for a previously obtained board ' . $boardId, ['exception' => $e]);
return [];
}
return $this->stackMapper->findAll($boardId); return $this->stackMapper->findAll($boardId);
} }