Updated userSchema to store flair by reference
This commit is contained in:
parent
108290de2d
commit
279640a7e7
7 changed files with 73 additions and 54 deletions
|
|
@ -38,7 +38,8 @@ module.exports = class{
|
|||
//Add this socket on to the userobject
|
||||
userObj.sockets.push(socket.id);
|
||||
}else{
|
||||
userObj = new connectedUser(userDB.user, userDB.id, userDB.rank, chanRank, userDB.flair, this, socket);
|
||||
await userDB.populate('flair');
|
||||
userObj = new connectedUser(userDB.user, userDB.id, userDB.rank, chanRank, userDB.flair.name, this, socket);
|
||||
}
|
||||
|
||||
//Set user entry in userlist
|
||||
|
|
|
|||
|
|
@ -58,13 +58,12 @@ module.exports = class{
|
|||
if(userDB){
|
||||
try{
|
||||
//We can take this data raw since our schema checks it against existing flairs, and mongoose sanatizes queries
|
||||
userDB.flair = data.flair;
|
||||
userDB = await userDB.save();
|
||||
const flairDB = await userDB.setFlair(data.flair);
|
||||
|
||||
const connections = this.server.getConnections(socket.user.user);
|
||||
|
||||
connections.forEach((conn) => {
|
||||
conn.updateFlair(userDB.flair);
|
||||
conn.updateFlair(flairDB.name);
|
||||
});
|
||||
}catch(err){
|
||||
return loggerUtils.socketExceptionHandler(socket, err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue