mirror of
https://github.com/zadam/trilium.git
synced 2025-12-23 16:49:58 +01:00
protect/unprotect subtree
This commit is contained in:
@@ -9,6 +9,7 @@ const auth = require('../../services/auth');
|
||||
const log = require('../../services/log');
|
||||
const protected_session = require('../../services/protected_session');
|
||||
const data_encryption = require('../../services/data_encryption');
|
||||
const notes = require('../../services/notes');
|
||||
|
||||
router.get('/', auth.checkApiAuth, async (req, res, next) => {
|
||||
const notes = await sql.getResults("select "
|
||||
@@ -59,4 +60,16 @@ router.get('/', auth.checkApiAuth, async (req, res, next) => {
|
||||
});
|
||||
});
|
||||
|
||||
router.put('/:noteId/protectSubTree/:isProtected', auth.checkApiAuth, async (req, res, next) => {
|
||||
const noteId = req.params.noteId;
|
||||
const isProtected = !!parseInt(req.params.isProtected);
|
||||
const dataKey = protected_session.getDataKey(req);
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await notes.protectNoteRecursively(noteId, dataKey, isProtected);
|
||||
});
|
||||
|
||||
res.send({});
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user