mirror of https://github.com/calzoneman/sync.git
Add some safety checks to PMs
This commit is contained in:
parent
b41529d4aa
commit
ad30e3a805
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ function addUserDropdown(entry) {
|
|||
}
|
||||
|
||||
/* pm button */
|
||||
if (name !== CLIENT.name) {
|
||||
var pm = $("<button/>").addClass("btn btn-xs btn-default")
|
||||
.text("Private Message")
|
||||
.appendTo(btngroup)
|
||||
|
@ -207,6 +208,7 @@ function addUserDropdown(entry) {
|
|||
initPm(name).find(".panel-heading").click();
|
||||
menu.hide();
|
||||
});
|
||||
}
|
||||
|
||||
/* give/remove leader (moderator+ only) */
|
||||
if (hasPermission("leaderctl")) {
|
||||
|
|
Loading…
Reference in New Issue