Files
wekan/server/lib/cardCopyDestination.js
Lauri Ojansivu c35ba4b35e Validate server card-copy destinations before reads and writes
Require existing destination containers on the requested board before sort
reads, number allocation, field remapping and child copies. Reject soft-deleted
containers and return a clear REST input error without security-account blocks.
Preserve board-wide lists and archived-container board-copy behavior.

Cover invalid and valid placement with unit, DDP, REST and browser tests,
including existing ordinary, rule, Scrum, list and swimlane copy paths.
Record the remaining source-access and concurrent-write review.

Thanks to xet7 !
2026-09-29 00:13:43 +03:00

22 lines
992 B
JavaScript

import { Meteor } from 'meteor/meteor';
import Boards from '/models/boards';
import Lists from '/models/lists';
import Swimlanes from '/models/swimlanes';
const { validCardCopyDestination } = require('/models/lib/cardCopyDestination');
export async function requireCardCopyDestination(boardId, swimlaneId, listId) {
let records = [];
if ([boardId, swimlaneId, listId].every(id => typeof id === 'string' && id.length > 0)) {
records = await Promise.all([
Boards.findOneAsync(boardId, { fields: { _id: 1, deletedAt: 1 } }),
Swimlanes.findOneAsync({ _id: swimlaneId, boardId }, { fields: { boardId: 1, deletedAt: 1 } }),
Lists.findOneAsync({ _id: listId, boardId }, { fields: { boardId: 1, deletedAt: 1 } }),
]);
}
if (!validCardCopyDestination(boardId, swimlaneId, listId, ...records)) {
const error = new Meteor.Error('invalid-copy-destination', 'Choose a list and swimlane on the destination board.');
error.statusCode = 400;
throw error;
}
}