adding missing .getPojo() to becca entities

This commit is contained in:
zadam 2021-05-08 22:13:08 +02:00
parent 9441cb177f
commit 84246fd197
4 changed files with 44 additions and 6 deletions

View file

@ -18,6 +18,14 @@ class ApiToken extends AbstractEntity {
this.token = row.token;
this.utcDateCreated = row.utcDateCreated || dateUtils.utcNowDateTime();
}
getPojo() {
return {
apiTokenId: this.apiTokenId,
token: this.token,
utcDateCreated: this.utcDateCreated
}
}
}
module.exports = ApiToken;

View file

@ -141,11 +141,24 @@ class NoteRevision extends AbstractEntity {
this.utcDateModified = dateUtils.utcNowDateTime();
}
// cannot be static!
updatePojo(pojo) {
getPojo() {
const pojo = {
noteRevisionId: this.noteRevisionId,
noteId: this.noteId,
type: this.type,
mime: this.mime,
isProtected: this.isProtected,
title: this.title,
dateLastEdited: this.dateLastEdited,
dateCreated: this.dateCreated,
utcDateLastEdited: this.utcDateLastEdited,
utcDateCreated: this.utcDateCreated,
utcDateModified: this.utcDateModified
};
if (pojo.isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) {
pojo.title = protectedSessionService.encrypt(pojo.title);
pojo.title = protectedSessionService.encrypt(this.title);
}
else {
// updating protected note outside of protected session means we will keep original ciphertexts
@ -153,7 +166,7 @@ class NoteRevision extends AbstractEntity {
}
}
delete pojo.content;
return pojo;
}
}

View file

@ -26,8 +26,17 @@ class Option extends AbstractEntity {
super.beforeSaving();
this.utcDateModified = dateUtils.utcNowDateTime();
// utcDateCreated is scheduled for removal so the value does not matter
this.utcDateCreated = dateUtils.utcNowDateTime();
}
getPojo() {
return {
name: this.name,
value: this.value,
isSynced: this.isSynced,
utcDateModified: this.utcDateModified,
// utcDateCreated is scheduled for removal so the value does not matter
utcDateCreated: dateUtils.utcNowDateTime()
}
}
}

View file

@ -17,6 +17,14 @@ class RecentNote extends AbstractEntity {
this.notePath = row.notePath;
this.utcDateCreated = row.utcDateCreated || dateUtils.utcNowDateTime();
}
getPojo() {
return {
noteId: this.noteId,
notePath: this.notePath,
utcDateCreated: this.utcDateCreated
}
}
}
module.exports = RecentNote;