mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 10:35:55 +01:00
closes #3997
This commit is contained in:
@@ -65,6 +65,8 @@ chatsController.get = function(req, res, callback) {
|
||||
room.nextStart = recentChats.nextStart;
|
||||
room.title = room.roomName;
|
||||
room.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:chats]]', url: '/chats'}, {text: room.roomName}]);
|
||||
room.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
|
||||
room.showUserInput = !room.maximumUsersInChatRoom || room.maximumUsersInChatRoom > 2;
|
||||
|
||||
res.render('chats', room);
|
||||
});
|
||||
|
||||
@@ -125,6 +125,8 @@ SocketModules.chats.loadRoom = function(socket, data, callback) {
|
||||
function (results, next) {
|
||||
results.roomData.users = results.users;
|
||||
results.roomData.isOwner = parseInt(results.roomData.owner, 10) === socket.uid;
|
||||
results.roomData.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
|
||||
results.roomData.showUserInput = !results.roomData.maximumUsersInChatRoom || results.roomData.maximumUsersInChatRoom > 2;
|
||||
next(null, results.roomData);
|
||||
}
|
||||
], callback);
|
||||
@@ -135,6 +137,16 @@ SocketModules.chats.addUserToRoom = function(socket, data, callback) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Messaging.getUserCountInRoom(data.roomId, next);
|
||||
},
|
||||
function (userCount, next) {
|
||||
var maxUsers = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
|
||||
if (maxUsers && userCount >= maxUsers) {
|
||||
return next(new Error('[[error:cant-add-more-users-to-chat-room]]'));
|
||||
}
|
||||
next();
|
||||
},
|
||||
function (next) {
|
||||
user.getUidByUsername(data.username, next);
|
||||
},
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
<label>Maximum length of chat messages</label>
|
||||
<input type="text" class="form-control" value="1000" data-field="maximumChatMessageLength">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Maximum number of users in chat rooms</label>
|
||||
<input type="text" class="form-control" value="0" data-field="maximumUsersInChatRoom">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user