unified/simplified protecting notes & subtree

This commit is contained in:
zadam
2020-02-26 16:37:17 +01:00
parent 3752cf8cba
commit 7bcae9981b
13 changed files with 84 additions and 90 deletions

View File

@@ -83,14 +83,15 @@ async function sortNotes(req) {
await treeService.sortNotesAlphabetically(noteId);
}
async function protectSubtree(req) {
async function protectNote(req) {
const noteId = req.params.noteId;
const note = await repository.getNote(noteId);
const protect = !!parseInt(req.params.isProtected);
const includingSubTree = !!parseInt(req.query.subtree);
const taskContext = new TaskContext(utils.randomString(10), 'protect-notes', {protect});
await noteService.protectNoteRecursively(note, protect, taskContext);
await noteService.protectNoteRecursively(note, protect, includingSubTree, taskContext);
taskContext.taskSucceeded();
}
@@ -183,7 +184,7 @@ module.exports = {
undeleteNote,
createNote,
sortNotes,
protectSubtree,
protectNote,
setNoteTypeMime,
getRelationMap,
changeTitle,

View File

@@ -134,7 +134,7 @@ function register(app) {
apiRoute(PUT, '/api/notes/:noteId/undelete', notesApiRoute.undeleteNote);
apiRoute(POST, '/api/notes/:parentNoteId/children', notesApiRoute.createNote);
apiRoute(PUT, '/api/notes/:noteId/sort', notesApiRoute.sortNotes);
apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectSubtree);
apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectNote);
apiRoute(PUT, /\/api\/notes\/(.*)\/type\/(.*)\/mime\/(.*)/, notesApiRoute.setNoteTypeMime);
apiRoute(GET, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.getNoteRevisions);
apiRoute(DELETE, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.eraseAllNoteRevisions);