Add some safety checks to PMs

This commit is contained in:
calzoneman 2014-02-15 12:29:05 -06:00
parent b41529d4aa
commit ad30e3a805
2 changed files with 26 additions and 7 deletions

View file

@ -2878,6 +2878,20 @@ Channel.prototype.handlePm = function (user, data) {
return;
}
if (data.to === user.name) {
user.socket.emit("errorMsg", {
msg: "You can't PM yourself!"
});
return;
}
if (!util.isValidUserName(data.to)) {
user.socket.emit("errorMsg", {
msg: data.to + " isn't a valid username."
});
return;
}
var msg = data.msg.substring(0, 240);
var to = null;
for (var i = 0; i < this.users.length; i++) {
@ -2888,6 +2902,9 @@ Channel.prototype.handlePm = function (user, data) {
}
if (!to) {
user.socket.emit("errorMsg", {
msg: data.to + " is not on this channel."
});
return;
}