mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
also de-encryption of note history plus bug fixes
This commit is contained in:
parent
471f7c669d
commit
ac0e5ada6e
@ -235,31 +235,39 @@ function encryptNoteAndSendToServer() {
|
|||||||
|
|
||||||
saveNoteToServer(note);
|
saveNoteToServer(note);
|
||||||
|
|
||||||
encryptNoteHistory(note.detail.note_id);
|
changeEncryptionOnNoteHistory(note.detail.note_id, true);
|
||||||
|
|
||||||
setNoteBackgroundIfEncrypted(note);
|
setNoteBackgroundIfEncrypted(note);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function encryptNoteHistory(noteId) {
|
function changeEncryptionOnNoteHistory(noteId, encrypt) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: baseApiUrl + 'notes-history/' + noteId + "?encryption=0",
|
url: baseApiUrl + 'notes-history/' + noteId + "?encryption=" + (encrypt ? 0 : 1),
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
success: result => {
|
success: result => {
|
||||||
for (const row of result) {
|
for (const row of result) {
|
||||||
|
if (encrypt) {
|
||||||
row.note_title = encryptString(row.note_title);
|
row.note_title = encryptString(row.note_title);
|
||||||
row.note_text = encryptString(row.note_text);
|
row.note_text = encryptString(row.note_text);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
row.note_title = decryptString(row.note_title);
|
||||||
|
row.note_text = decryptString(row.note_text);
|
||||||
|
}
|
||||||
|
|
||||||
row.encryption = 1;
|
row.encryption = encrypt ? 1 : 0;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: baseApiUrl + 'notes-history',
|
url: baseApiUrl + 'notes-history',
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
data: JSON.stringify(row),
|
data: JSON.stringify(row),
|
||||||
success: result => console.log('Note history ' + row.note_history_id + ' encrypted'),
|
success: result => console.log('Note history ' + row.note_history_id + ' de/encrypted'),
|
||||||
error: () => alert("Error encrypting note history.")
|
error: () => alert("Error de/encrypting note history.")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: () => alert("Error getting note history.")
|
error: () => alert("Error getting note history.")
|
||||||
@ -276,6 +284,8 @@ function decryptNoteAndSendToServer() {
|
|||||||
|
|
||||||
saveNoteToServer(note);
|
saveNoteToServer(note);
|
||||||
|
|
||||||
|
changeEncryptionOnNoteHistory(note.detail.note_id, false);
|
||||||
|
|
||||||
setNoteBackgroundIfEncrypted(note);
|
setNoteBackgroundIfEncrypted(note);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => {
|
|||||||
res.send(history);
|
res.send(history);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.put('/', auth.checkApiAuth, async (req, res, next) => {
|
router.put('', auth.checkApiAuth, async (req, res, next) => {
|
||||||
await sql.doInTransaction(async () => {
|
await sql.doInTransaction(async () => {
|
||||||
await sql.replace("notes_history", req.body);
|
await sql.replace("notes_history", req.body);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user