mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
closes #4123
This commit is contained in:
@@ -357,7 +357,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, '[[error:chat-disabled]]');
|
return callback(new Error('[[error:chat-disabled]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
@@ -366,20 +366,20 @@ var async = require('async'),
|
|||||||
},
|
},
|
||||||
function (inRoom, next) {
|
function (inRoom, next) {
|
||||||
if (!inRoom) {
|
if (!inRoom) {
|
||||||
return callback(null, false, '[[error:not-in-room]]');
|
return next(new Error('[[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, '[[error:user-banned]]');
|
return next(new Error('[[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, '[[error:email-not-confirmed-chat]]');
|
return next(new Error('[[error:email-not-confirmed-chat]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
next(null, true);
|
next();
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -85,21 +85,19 @@ SocketModules.chats.send = function(socket, data, callback) {
|
|||||||
socket.lastChatMessageTime = now;
|
socket.lastChatMessageTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messaging.canMessageRoom(socket.uid, data.roomId, function(err, allowed, notAllowedMessage) {
|
async.waterfall([
|
||||||
if (err || !allowed) {
|
function (next) {
|
||||||
return callback(err || new Error(notAllowedMessage));
|
Messaging.canMessageRoom(socket.uid, data.roomId, next);
|
||||||
}
|
},
|
||||||
|
function (next) {
|
||||||
Messaging.sendMessage(socket.uid, data.roomId, data.message, now, function(err, message) {
|
Messaging.sendMessage(socket.uid, data.roomId, data.message, now, next);
|
||||||
if (err) {
|
},
|
||||||
return callback(err);
|
function (message, next) {
|
||||||
}
|
|
||||||
|
|
||||||
Messaging.notifyUsersInRoom(socket.uid, data.roomId, message);
|
Messaging.notifyUsersInRoom(socket.uid, data.roomId, message);
|
||||||
|
user.updateOnlineUsers(socket.uid);
|
||||||
callback();
|
next();
|
||||||
});
|
}
|
||||||
});
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketModules.chats.loadRoom = function(socket, data, callback) {
|
SocketModules.chats.loadRoom = function(socket, data, callback) {
|
||||||
@@ -217,12 +215,7 @@ 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, notAllowedMessage) {
|
Messaging.canMessageRoom(socket.uid, roomId, callback);
|
||||||
if (err || !allowed) {
|
|
||||||
return callback(err || new Error(notAllowedMessage));
|
|
||||||
}
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketModules.chats.markRead = function(socket, roomId, callback) {
|
SocketModules.chats.markRead = function(socket, roomId, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user