diff --git a/lib/channel.js b/lib/channel.js
index 9e8a760c..004ab61d 100644
--- a/lib/channel.js
+++ b/lib/channel.js
@@ -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;
}
diff --git a/www/assets/js/util.js b/www/assets/js/util.js
index 1d1b67c4..6adf1859 100644
--- a/www/assets/js/util.js
+++ b/www/assets/js/util.js
@@ -200,13 +200,15 @@ function addUserDropdown(entry) {
}
/* pm button */
- var pm = $("").addClass("btn btn-xs btn-default")
- .text("Private Message")
- .appendTo(btngroup)
- .click(function () {
- initPm(name).find(".panel-heading").click();
- menu.hide();
- });
+ if (name !== CLIENT.name) {
+ var pm = $("").addClass("btn btn-xs btn-default")
+ .text("Private Message")
+ .appendTo(btngroup)
+ .click(function () {
+ initPm(name).find(".panel-heading").click();
+ menu.hide();
+ });
+ }
/* give/remove leader (moderator+ only) */
if (hasPermission("leaderctl")) {