class User { constructor(info){ if(!info || !info.userid) throw new Error("Cannot construct empty profile"); this.userid = info.userid; this.profile = { firstName: info.profile?.firstName || '', lastName: info.profile?.lastName || '', photo: info.profile?.photo || '', location: info.profile?.location || 'USA', language: info.profile?.language || 'en', status: info.profile?.status || '', description: 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 = JSON.parse(JSON.stringify(info.subscribed || {})); //Subscribed user to groups this.pending = JSON.parse(JSON.stringify(info.pending || {})); //Private groups require authorization } toObj(){ return { ...this }; } } module.exports = User;