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