mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
closes #3929
This commit is contained in:
@@ -98,6 +98,7 @@
|
||||
|
||||
"cant-chat-with-yourself": "You can't chat with yourself!",
|
||||
"chat-restricted": "This user has restricted their chat messages. They must follow you before you can chat with them",
|
||||
"chat-disabled": "Chat system disabled",
|
||||
"too-many-messages": "You have sent too many messages, please wait awhile.",
|
||||
"invalid-chat-message": "Invalid chat message",
|
||||
"chat-message-too-long": "Chat message is too long",
|
||||
|
||||
@@ -273,13 +273,6 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
|
||||
|
||||
checkStatus(chatModal);
|
||||
|
||||
module.canMessage(data.roomId, function(err) {
|
||||
if (err) {
|
||||
// Disable the text input
|
||||
chatModal.find('input[type="text"]').attr('disabled', true);
|
||||
}
|
||||
});
|
||||
|
||||
taskbar.push('chat', chatModal.attr('UUID'), {
|
||||
title: data.users.length ? data.users[0].username : '',
|
||||
roomId: data.roomId,
|
||||
@@ -380,11 +373,6 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
|
||||
|
||||
module.toggleNew = taskbar.toggleNew;
|
||||
|
||||
module.canMessage = function(roomId, callback) {
|
||||
socket.emit('modules.chats.canMessage', roomId, callback);
|
||||
};
|
||||
|
||||
|
||||
|
||||
return module;
|
||||
});
|
||||
|
||||
@@ -46,7 +46,6 @@ chatsController.get = function(req, res, callback) {
|
||||
since: 'recent',
|
||||
isNew: false
|
||||
}),
|
||||
allowed: async.apply(messaging.canMessageRoom, req.uid, req.params.roomid),
|
||||
owner: async.apply(messaging.isRoomOwner, req.uid, req.params.roomid)
|
||||
}, next);
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ var async = require('async'),
|
||||
|
||||
Messaging.canMessageRoom = function(uid, roomId, callback) {
|
||||
if (parseInt(meta.config.disableChat) === 1 || !uid) {
|
||||
return callback(null, false);
|
||||
return callback(null, false, '[[error:chat-disabled]]');
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
@@ -364,17 +364,17 @@ var async = require('async'),
|
||||
},
|
||||
function (inRoom, next) {
|
||||
if (!inRoom) {
|
||||
return callback(null, false);
|
||||
return callback(null, false, '[[error:not-in-room]]');
|
||||
}
|
||||
user.getUserFields(uid, ['banned', 'email:confirmed'], next);
|
||||
},
|
||||
function (userData, next) {
|
||||
if (parseInt(userData.banned, 10) === 1) {
|
||||
return callback(null, false);
|
||||
return callback(null, false, '[[error:user-banned]]');
|
||||
}
|
||||
|
||||
if (parseInt(meta.config.requireEmailConfirmation, 10) === 1 && parseInt(userData['email:confirmed'], 10) !== 1) {
|
||||
return callback(null, false);
|
||||
return callback(null, false, '[[error:email-not-confirmed-chat]]');
|
||||
}
|
||||
|
||||
next(null, true);
|
||||
|
||||
@@ -84,9 +84,9 @@ SocketModules.chats.send = function(socket, data, callback) {
|
||||
socket.lastChatMessageTime = now;
|
||||
}
|
||||
|
||||
Messaging.canMessageRoom(socket.uid, data.roomId, function(err, allowed) {
|
||||
Messaging.canMessageRoom(socket.uid, data.roomId, function(err, allowed, notAllowedMessage) {
|
||||
if (err || !allowed) {
|
||||
return callback(err || new Error('[[error:chat-restricted]]'));
|
||||
return callback(err || new Error(notAllowedMessage));
|
||||
}
|
||||
|
||||
Messaging.sendMessage(socket.uid, data.roomId, data.message, now, function(err, message) {
|
||||
@@ -183,8 +183,11 @@ SocketModules.chats.delete = function(socket, data, callback) {
|
||||
};
|
||||
|
||||
SocketModules.chats.canMessage = function(socket, roomId, callback) {
|
||||
Messaging.canMessageRoom(socket.uid, roomId, function(err, allowed) {
|
||||
callback(!allowed ? new Error('[[error:chat-restricted]]') : undefined);
|
||||
Messaging.canMessageRoom(socket.uid, roomId, function(err, allowed, notAllowedMessage) {
|
||||
if (err || !allowed) {
|
||||
return callback(err || new Error(notAllowedMessage));
|
||||
}
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user