rename to profile, users are people

This commit is contained in:
Adolfo Reyna
2021-08-18 07:57:19 -07:00
parent 416c14d03b
commit 95a7bcb3ff
6 changed files with 46 additions and 33 deletions

View File

@@ -1,14 +1,14 @@
class Post {
constructor(info){
if(!info || !info.userid) throw "Can not construct empty posts";
this.userid = info.userid;
if(!info || !info.profileid) throw "Can not construct empty posts";
this.profileid = info.profileid;
this.content = info.content;
this.createdAt = info.createdAt || new Date();
this.reactions = info.reactions || {};
this.comments = info.comments || [];
//This should record edits
this.contentHistory = info.contentHistory || [];
this.toUser = info.toUser || '';
this.toProfile = info.toProfile || '';
// Any reaction or comment updates this ts,
// this will be used as index to query new posts
this.lastUpdated = info.lastUpdated || this.createdAt;
@@ -20,26 +20,26 @@ class Post {
}
addReaction(reaction){
if(this.reactions[reaction.userid] &&
this.reactions[reaction.userid].type === reaction.type){
delete this.reactions[reaction.userid]
if(this.reactions[reaction.profileid] &&
this.reactions[reaction.profileid].type === reaction.type){
delete this.reactions[reaction.profileid]
}
else{
this.reactions[reaction.userid] = reaction;
this.reactions[reaction.profileid] = reaction;
}
this.lastUpdated = new Date();
}
toObj=function(){
let r = {}
r.userid = this.userid;
r.profileid = this.profileid;
r.content = this.content;
r.createdAt = this.createdAt;
r.reactions = this.reactions;
r.comments = this.comments;
r.contentHistory = this.contentHistory;
r.lastUpdated = this.lastUpdated;
r.toUser = this.toUser;
r.toProfile = this.toProfile;
return r;
}
}