fix: Only query boards not marked for deletion unless we want to undo
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -181,7 +181,7 @@ class BoardService {
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public function find($boardId) {
|
||||
public function find($boardId, bool $allowDeleted = false) {
|
||||
$this->boardServiceValidator->check(compact('boardId'));
|
||||
if ($this->boardsCache && isset($this->boardsCache[$boardId])) {
|
||||
return $this->boardsCache[$boardId];
|
||||
@@ -192,7 +192,7 @@ class BoardService {
|
||||
|
||||
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
||||
/** @var Board $board */
|
||||
$board = $this->boardMapper->find($boardId, true, true);
|
||||
$board = $this->boardMapper->find($boardId, true, true, $allowDeleted);
|
||||
$this->boardMapper->mapOwner($board);
|
||||
if ($board->getAcl() !== null) {
|
||||
foreach ($board->getAcl() as $acl) {
|
||||
@@ -367,7 +367,7 @@ class BoardService {
|
||||
$this->boardServiceValidator->check(compact('id'));
|
||||
|
||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
||||
$board = $this->find($id);
|
||||
$board = $this->find($id, true);
|
||||
$board->setDeletedAt(0);
|
||||
$board = $this->boardMapper->update($board);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_RESTORE);
|
||||
@@ -388,7 +388,7 @@ class BoardService {
|
||||
$this->boardServiceValidator->check(compact('id'));
|
||||
|
||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
||||
$board = $this->find($id);
|
||||
$board = $this->find($id, true);
|
||||
$delete = $this->boardMapper->delete($board);
|
||||
|
||||
return $delete;
|
||||
|
||||
@@ -274,6 +274,14 @@ class CardService {
|
||||
if ($archived !== null && $card->getArchived() && $archived === true) {
|
||||
throw new StatusException('Operation not allowed. This card is archived.');
|
||||
}
|
||||
|
||||
if ($card->getDeletedAt() !== 0) {
|
||||
if ($deletedAt === null) {
|
||||
// Only allow operations when restoring the card
|
||||
throw new StatusException('Operation not allowed. This card was deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
$changes = new ChangeSet($card);
|
||||
if ($card->getLastEditor() !== $this->currentUser && $card->getLastEditor() !== null) {
|
||||
$this->activityManager->triggerEvent(
|
||||
|
||||
@@ -194,11 +194,11 @@ class PermissionService {
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
private function getBoard($boardId): Board {
|
||||
if (!isset($this->boardCache[$boardId])) {
|
||||
$this->boardCache[$boardId] = $this->boardMapper->find($boardId, false, true);
|
||||
private function getBoard(int $boardId): Board {
|
||||
if (!isset($this->boardCache[(string)$boardId])) {
|
||||
$this->boardCache[(string)$boardId] = $this->boardMapper->find($boardId, false, true);
|
||||
}
|
||||
return $this->boardCache[$boardId];
|
||||
return $this->boardCache[(string)$boardId];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user