|
|
|
|
@ -14,21 +14,34 @@ function protectRevisions(note) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const revision of note.getRevisions()) {
|
|
|
|
|
if (note.isProtected === revision.isProtected) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (note.isProtected !== revision.isProtected) {
|
|
|
|
|
try {
|
|
|
|
|
const content = revision.getContent();
|
|
|
|
|
|
|
|
|
|
revision.isProtected = note.isProtected;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const content = revision.getContent();
|
|
|
|
|
// this will force de/encryption
|
|
|
|
|
revision.setContent(content, {forceSave: true});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(`Could not un/protect note revision '${revision.revisionId}'`);
|
|
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
revision.isProtected = note.isProtected;
|
|
|
|
|
for (const attachment of revision.getAttachments()) {
|
|
|
|
|
if (note.isProtected !== attachment.isProtected) {
|
|
|
|
|
try {
|
|
|
|
|
const content = attachment.getContent();
|
|
|
|
|
|
|
|
|
|
// this will force de/encryption
|
|
|
|
|
revision.setContent(content, {forceSave: true});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(`Could not un/protect note revision '${revision.revisionId}'`);
|
|
|
|
|
attachment.isProtected = note.isProtected;
|
|
|
|
|
attachment.setContent(content, {forceSave: true});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log.error(`Could not un/protect attachment '${attachment.attachmentId}'`);
|
|
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|