38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
class User {
|
|
constructor(info){
|
|
if(!info || !info.userid) throw "Can not construct empty profile";
|
|
this.userid = info.userid;
|
|
this.profile = {
|
|
firstName: info.profile && info.profile.firstName || '',
|
|
lastName: info.profile && info.profile.lastName || '',
|
|
photo: info.profile && info.profile.photo || '',
|
|
location: info.profile && info.profile.location || '',
|
|
language: info.profile && info.profile.language || '',
|
|
status: info.profile && info.profile.status || '',
|
|
description: info.profile && info.profile.description || '',
|
|
};
|
|
this.data = info.data || {};
|
|
this.username = info.username || '';
|
|
this.following = info.following || [];
|
|
this.lastUpdate = info.lastUpdate || new Date();
|
|
this.newsFeedCache = info.newsFeedCache || [];
|
|
this.isGroup = info.isGroup || false;
|
|
}
|
|
|
|
toObj(){
|
|
let r = {};
|
|
r.userid = this.userid
|
|
r.username = this.username;
|
|
r.profile = this.profile;
|
|
r.data = this.data;
|
|
r.username = this.username;
|
|
r.following = this.following;
|
|
r.lastUpdate = this.lastUpdate;
|
|
r.newsFeedCache = this.newsFeedCache;
|
|
r.isGroup = this.isGroup;
|
|
return r;
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = User; |