encryption updates

This commit is contained in:
Mo Bitar
2016-12-12 20:00:21 -06:00
parent 8ad3776819
commit d200df0b85
12 changed files with 136 additions and 144 deletions

View File

@@ -0,0 +1,3 @@
var Group = function (json_obj) {
_.merge(this, json_obj);
};

View File

@@ -23,6 +23,10 @@ var Note = function (json_obj) {
enumerable: true,
});
this.setContentRaw = function(rawContent) {
content = rawContent;
}
_.merge(this, json_obj);
if(!this.content) {
@@ -30,17 +34,22 @@ var Note = function (json_obj) {
}
};
Note.filterDummyNotes = function(notes) {
var filtered = notes.filter(function(note){return note.dummy == false || note.dummy == null});
return filtered;
}
/* Returns true if note is shared individually or via group */
Note.prototype.isPublic = function() {
return this.hasEnabledPresentation() || this.shared_via_group;
return this.presentation || (this.group && this.group.presentation);
};
Note.prototype.isEncrypted = function() {
return (this.loc_eek || this.local_eek) && typeof this.content === 'string' ? true : false;
return this.encryptionEnabled() && typeof this.content === 'string' ? true : false;
}
Note.prototype.hasEnabledPresentation = function() {
return this.presentation && this.presentation.enabled;
Note.prototype.encryptionEnabled = function() {
return this.loc_eek;
}
Note.prototype.presentationURL = function() {

View File

@@ -1,3 +1,23 @@
var User = function (json_obj) {
_.merge(this, json_obj);
this.notes = _.map(this.notes, function(json_obj) {
return new Note(json_obj);
});
this.groups = _.map(this.groups, function(json_obj) {
return new Group(json_obj);
});
this.groups.forEach(function(group){
var notes = this.notes.filter(function(note){return note.group_id && note.group_id == group.id});
notes.forEach(function(note){
note.group = group;
})
group.notes = notes;
}.bind(this))
};
User.prototype.filteredNotes = function() {
return Note.filterDummyNotes(this.notes);
}