More fixes

This commit is contained in:
calzoneman 2014-01-26 00:13:33 -06:00
parent 6570c3da6c
commit 0f82faaef8
3 changed files with 33 additions and 3 deletions

View file

@ -1137,6 +1137,20 @@ Channel.prototype.sendRecentChat = function (users) {
});
};
/**
* Sends a user profile
*/
Channel.prototype.sendUserProfile = function (users, user) {
var packet = {
name: user.name,
profile: user.profile
};
users.forEach(function (u) {
u.socket.emit("setUserProfile", packet);
});
};
/**
* Packs userdata for addUser or userlist
*/

View file

@ -58,6 +58,18 @@ function User(socket) {
if (announcement != null) {
self.socket.emit("announcement", announcement);
}
self.on("login", function () {
db.recordVisit(self.ip, self.name);
db.users.getProfile(self.name, function (err, profile) {
if (!err) {
self.profile = profile;
if (self.inChannel()) {
self.channel.sendUserProfile(self.channel.users, self);
}
}
});
});
}
/**