Cover case where the owner is preserved

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2022-03-21 13:42:15 +01:00
parent eb69512b5f
commit 379f1144b3
4 changed files with 56 additions and 17 deletions

View File

@@ -24,6 +24,7 @@
namespace OCA\Deck\Controller;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\Board;
use OCA\Deck\Service\BoardService;
use OCA\Deck\Service\PermissionService;
use OCP\AppFramework\ApiController;
@@ -152,7 +153,7 @@ class BoardController extends ApiController {
/**
* @NoAdminRequired
* @param $boardId
* @return \OCP\Deck\DB\Board
* @return Board
*/
public function clone($boardId) {
return $this->boardService->clone($boardId, $this->userId);

View File

@@ -24,6 +24,7 @@
namespace OCA\Deck\Service;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OCA\Deck\Activity\ActivityManager;
use OCA\Deck\Activity\ChangeSet;
use OCA\Deck\AppInfo\Application;
@@ -694,6 +695,11 @@ class BoardService {
if ($changeContent) {
$this->assignedUsersMapper->remapAssignedUser($boardId, $previousOwner, $newOwner);
$this->cardMapper->remapCardOwner($boardId, $previousOwner, $newOwner);
} else {
try {
$this->addAcl($boardId, Acl::PERMISSION_TYPE_USER, $previousOwner, true, true, true);
} catch (UniqueConstraintViolationException $e) {
}
}
\OC::$server->getDatabaseConnection()->commit();
return $this->boardMapper->find($boardId);
@@ -706,7 +712,9 @@ class BoardService {
public function transferOwnership(string $owner, string $newOwner, bool $changeContent = false): \Generator {
$boards = $this->boardMapper->findAllByUser($owner);
foreach ($boards as $board) {
yield $this->transferBoardOwnership($board->getId(), $newOwner, $changeContent);
if ($board->getOwner() === $owner) {
yield $this->transferBoardOwnership($board->getId(), $newOwner, $changeContent);
}
}
}