updating becca after sync

This commit is contained in:
zadam
2021-08-07 21:21:30 +02:00
parent 669eaa7509
commit 86a53ceebb
8 changed files with 103 additions and 42 deletions

View File

@@ -108,7 +108,7 @@ class NoteRevision extends AbstractEntity {
}
}
setContent(content) {
setContent(content, ignoreMissingProtectedSession = false) {
const pojo = {
noteRevisionId: this.noteRevisionId,
content: content,
@@ -119,14 +119,14 @@ class NoteRevision extends AbstractEntity {
if (protectedSessionService.isProtectedSessionAvailable()) {
pojo.content = protectedSessionService.encrypt(pojo.content);
}
else {
else if (!ignoreMissingProtectedSession) {
throw new Error(`Cannot update content of noteRevisionId=${this.noteRevisionId} since we're out of protected session.`);
}
}
sql.upsert("note_revision_contents", "noteRevisionId", pojo);
const hash = utils.hash(this.noteRevisionId + "|" + content);
const hash = utils.hash(this.noteRevisionId + "|" + pojo.content.toString());
entityChangesService.addEntityChange({
entityName: 'note_revision_contents',
@@ -138,6 +138,17 @@ class NoteRevision extends AbstractEntity {
});
}
/** @returns {{contentLength, dateModified, utcDateModified}} */
getContentMetadata() {
return sql.getRow(`
SELECT
LENGTH(content) AS contentLength,
dateModified,
utcDateModified
FROM note_revision_contents
WHERE noteRevisionId = ?`, [this.noteRevisionId]);
}
beforeSaving() {
super.beforeSaving();