initial work on new router model

This commit is contained in:
azivner
2018-03-30 12:57:22 -04:00
parent 0ec909fd7a
commit efffc29649
5 changed files with 161 additions and 136 deletions

View File

@@ -4,28 +4,24 @@ const sql = require('./sql');
const sync_table = require('./sync_table');
const protected_session = require('./protected_session');
async function validateParentChild(res, parentNoteId, childNoteId, branchId = null) {
async function validateParentChild(parentNoteId, childNoteId, branchId = null) {
const existing = await getExistingBranch(parentNoteId, childNoteId);
if (existing && (branchId === null || existing.branchId !== branchId)) {
res.send({
return {
success: false,
message: 'This note already exists in the target.'
});
return false;
};
}
if (!await checkTreeCycle(parentNoteId, childNoteId)) {
res.send({
return {
success: false,
message: 'Moving note here would create cycle.'
});
return false;
};
}
return true;
return { success: true };
}
async function getExistingBranch(parentNoteId, childNoteId) {