fix creating tree cycle by moving clone into another clone, closes #4442

This commit is contained in:
zadam
2023-11-16 23:31:33 +01:00
parent 999cf0d9e3
commit 426a8f75aa
3 changed files with 22 additions and 16 deletions

View File

@@ -19,14 +19,14 @@ const ValidationError = require("../../errors/validation_error");
function moveBranchToParent(req) {
const {branchId, parentBranchId} = req.params;
const parentBranch = becca.getBranch(parentBranchId);
const branchToMove = becca.getBranch(branchId);
const targetParentBranch = becca.getBranch(parentBranchId);
if (!parentBranch || !branchToMove) {
if (!branchToMove || !targetParentBranch) {
throw new ValidationError(`One or both branches '${branchId}', '${parentBranchId}' have not been found`);
}
return branchService.moveBranchToBranch(branchToMove, parentBranch, branchId);
return branchService.moveBranchToBranch(branchToMove, targetParentBranch, branchId);
}
function moveBranchBeforeNote(req) {