mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	also de-encryption of note history plus bug fixes
This commit is contained in:
		| @@ -235,31 +235,39 @@ function encryptNoteAndSendToServer() { | ||||
|  | ||||
|         saveNoteToServer(note); | ||||
|  | ||||
|         encryptNoteHistory(note.detail.note_id); | ||||
|         changeEncryptionOnNoteHistory(note.detail.note_id, true); | ||||
|  | ||||
|         setNoteBackgroundIfEncrypted(note); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function encryptNoteHistory(noteId) { | ||||
| function changeEncryptionOnNoteHistory(noteId, encrypt) { | ||||
|     $.ajax({ | ||||
|         url: baseApiUrl + 'notes-history/' + noteId + "?encryption=0", | ||||
|         url: baseApiUrl + 'notes-history/' + noteId + "?encryption=" + (encrypt ? 0 : 1), | ||||
|         type: 'GET', | ||||
|         success: result => { | ||||
|             for (const row of result) { | ||||
|                 row.note_title = encryptString(row.note_title); | ||||
|                 row.note_text = encryptString(row.note_text); | ||||
|                 if (encrypt) { | ||||
|                     row.note_title = encryptString(row.note_title); | ||||
|                     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({ | ||||
|                     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.") | ||||
|                     success: result => console.log('Note history ' + row.note_history_id + ' de/encrypted'), | ||||
|                     error: () => alert("Error de/encrypting note history.") | ||||
|                 }); | ||||
|  | ||||
|                 break; | ||||
|             } | ||||
|         }, | ||||
|         error: () => alert("Error getting note history.") | ||||
| @@ -276,6 +284,8 @@ function decryptNoteAndSendToServer() { | ||||
|  | ||||
|         saveNoteToServer(note); | ||||
|  | ||||
|         changeEncryptionOnNoteHistory(note.detail.note_id, false); | ||||
|  | ||||
|         setNoteBackgroundIfEncrypted(note); | ||||
|     }); | ||||
| } | ||||
|   | ||||
| @@ -21,7 +21,7 @@ router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => { | ||||
|     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.replace("notes_history", req.body); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user