encryption of note history if the note is encrypted

This commit is contained in:
azivner
2017-11-02 23:36:58 -04:00
parent 4073f6a967
commit 471f7c669d
3 changed files with 58 additions and 5 deletions

View File

@@ -7,10 +7,28 @@ const auth = require('../../services/auth');
router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => {
const noteId = req.params.noteId;
const encryption = req.query.encryption;
const history = await sql.getResults("select * from notes_history where note_id = ? order by date_modified_to desc", [noteId]);
let history;
if (encryption === undefined) {
history = await sql.getResults("select * from notes_history where note_id = ? order by date_modified_to desc", [noteId]);
}
else {
history = await sql.getResults("select * from notes_history where note_id = ? and encryption = ? order by date_modified_to desc", [noteId, encryption]);
}
res.send(history);
});
router.put('/', auth.checkApiAuth, async (req, res, next) => {
await sql.doInTransaction(async () => {
await sql.replace("notes_history", req.body);
await sql.addNoteHistorySync(req.body.note_history_id);
});
res.send();
});
module.exports = router;