fixes for invalid operations on root note

This commit is contained in:
azivner
2018-10-21 22:42:20 +02:00
parent bfa2b5fa62
commit 0c007566ad
10 changed files with 51 additions and 9 deletions

View File

@@ -7,6 +7,15 @@ const syncTableService = require('./sync_table');
const protectedSessionService = require('./protected_session');
async function validateParentChild(parentNoteId, childNoteId, branchId = null) {
if (childNoteId === 'root') {
return { success: false, message: 'Cannot move root note.'};
}
if (parentNoteId === 'none') {
// this shouldn't happen
return { success: false, message: 'Cannot move anything into root parent.' };
}
const existing = await getExistingBranch(parentNoteId, childNoteId);
if (existing && (branchId === null || existing.branchId !== branchId)) {