expose ability to create note revisions in backend API #2890

This commit is contained in:
zadam
2022-06-02 17:25:58 +02:00
parent 103aa95ccf
commit 3cfca27b54
10 changed files with 949 additions and 285 deletions

View File

@@ -491,7 +491,7 @@ function saveLinks(note, content) {
return content;
}
function saveNoteRevision(note) {
function saveNoteRevisionIfNeeded(note) {
// files and images are versioned separately
if (note.type === 'file' || note.type === 'image' || note.hasLabel('disableVersioning')) {
return;
@@ -508,7 +508,7 @@ function saveNoteRevision(note) {
const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.utcDateCreated).getTime();
if (!existingNoteRevisionId && msSinceDateCreated >= noteRevisionSnapshotTimeInterval * 1000) {
noteRevisionService.createNoteRevision(note);
note.saveNoteRevision();
}
}
@@ -519,7 +519,7 @@ function updateNote(noteId, noteUpdates) {
throw new Error(`Note '${noteId}' is not available for change!`);
}
saveNoteRevision(note);
saveNoteRevisionIfNeeded(note);
// if protected status changed, then we need to encrypt/decrypt the content anyway
if (['file', 'image'].includes(note.type) && note.isProtected !== noteUpdates.isProtected) {
@@ -910,6 +910,6 @@ module.exports = {
triggerNoteTitleChanged,
eraseDeletedNotesNow,
eraseNotesWithDeleteId,
saveNoteRevision,
saveNoteRevisionIfNeeded,
downloadImages
};