start support for songs

This commit is contained in:
Adolfo Reyna
2023-05-31 06:11:50 -04:00
parent 3d3dab58f9
commit 2f726a5331
9 changed files with 640 additions and 18 deletions

View File

@@ -28,24 +28,7 @@ class User {
}
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.notifications = this.notifications;
r.isGroup = this.isGroup;
r.isCourse = this.isCourse;
r.isPrivate = this.isPrivate;
r.isChat = this.isChat;
r.subscribed = this.subscribed;
r.pending = this.pending;
return r;
return { ...this };
}
}

24
def/songs.js Normal file
View File

@@ -0,0 +1,24 @@
class Songs {
constructor(info) {
if (!info || !info.userid) throw "Can not construct empty profile";
this.userid = info.userid;
this.data = info.data || {};
const allowedParams = ["title", 'author', "content", "contentHistory", "bpm", "lang", "reactions", "root", 'beatsPerTempo'];
for (const key in info) {
if (info.hasOwnProperty(key) && allowedParams.includes(key)) {
this[key] = info[key];
}
}
this.createdAt = info.createdAt || new Date();
this.lastUpdated = info.lastUpdated || this.createdAt;
this.comments = info.comments || [];
this.reactions = info.reactions || {};
}
toObj() {
return { ...this };
}
}
module.exports = Songs;