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

@@ -235,10 +235,37 @@ function encryptNoteAndSendToServer() {
saveNoteToServer(note);
encryptNoteHistory(note.detail.note_id);
setNoteBackgroundIfEncrypted(note);
});
}
function encryptNoteHistory(noteId) {
$.ajax({
url: baseApiUrl + 'notes-history/' + noteId + "?encryption=0",
type: 'GET',
success: result => {
for (const row of result) {
row.note_title = encryptString(row.note_title);
row.note_text = encryptString(row.note_text);
row.encryption = 1;
$.ajax({
url: baseApiUrl + 'notes-history',
type: 'PUT',
contentType: 'application/json',
data: JSON.stringify(row),
success: result => console.log('Note history ' + row.note_history_id + ' encrypted'),
error: () => alert("Error encrypting note history.")
});
}
},
error: () => alert("Error getting note history.")
});
}
function decryptNoteAndSendToServer() {
handleEncryption(true, true, () => {
const note = globalCurrentNote;