36 lines
1.4 KiB
JavaScript
36 lines
1.4 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 || 'USA',
|
|
language: info.profile && info.profile.language || 'en',
|
|
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.notifications = info.notifications || [];
|
|
|
|
//groupRelated
|
|
this.isGroup = info.isGroup || false;
|
|
this.isCourse = info.isCourse || false;
|
|
this.isPrivate = info.isPrivate || false;
|
|
this.isChat = info.isChat || false;
|
|
this.subscribed = info.subscribed || {}; //Subscribed user to groups
|
|
this.pending = info.pending || {}; //Private groups require authorization
|
|
}
|
|
|
|
toObj(){
|
|
return { ...this };
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = User; |