Skip to content

Node.js based forum software built for the modern web

closes #5140

Barış Soner Uşaklıcbd936c5474d
diff --git a/public/src/app.js b/public/src/app.js
index 442e57f373..cf8232e3e4 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -301,6 +301,10 @@ app.cacheBuster = null;
return app.alertError('[[error:not-logged-in]]');
}
+ if (parseInt(touid, 10) === parseInt(app.user.uid, 10)) {
+ return app.alertError('[[error:cant-chat-with-yourself]]');
+ }
+
socket.emit('modules.chats.newRoom', {touid: touid}, function (err, roomId) {
if (err) {
return app.alertError(err.message);
diff --git a/public/src/client/chats/search.js b/public/src/client/chats/search.js
index 82b3923d2d..7ed50deb09 100644
--- a/public/src/client/chats/search.js
+++ b/public/src/client/chats/search.js
@@ -41,7 +41,11 @@ define('forum/chats/search', ['components'], function (components) {
function displayResults(chatsListEl, data) {
chatsListEl.empty();
-
+
+ data.users = data.users.filter(function (user) {
+ return parseInt(user.uid, 10) !== parseInt(app.user.uid, 10);
+ });
+
if (!data.users.length) {
return chatsListEl.translateHtml('<li><div><span>[[users:no-users-found]]</span></div></li>');
}
diff --git a/src/messaging.js b/src/messaging.js
index a88ceabbbe..d69e70b000 100644
--- a/src/messaging.js
+++ b/src/messaging.js
@@ -367,6 +367,10 @@ var userNotifications = require('./user/notifications');
return callback(new Error('[[error:chat-disabled]]'));
}
+ if (parseInt(uid, 10) === parseInt(toUid, 10)) {
+ return callback(new Error('[[error:cant-chat-with-yourself'));
+ }
+
async.waterfall([
function (next) {
user.exists(toUid, next);