Skip to content

Node.js based forum software built for the modern web

throw error in chat if no users in room

pichalite6ecc05afd4f0
diff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.json
index e52b7767b1..bc54182a36 100644
--- a/public/language/en_GB/error.json
+++ b/public/language/en_GB/error.json
@@ -124,5 +124,6 @@
"invite-maximum-met": "You have invited the maximum amount of people (%1 out of %2).",
"no-session-found": "No login session found!",
- "not-in-room": "User not in room"
+ "not-in-room": "User not in room",
+ "no-users-in-room": "No users in this room"
}
diff --git a/src/messaging.js b/src/messaging.js
index e78664d6d0..e39e9f0d3b 100644
--- a/src/messaging.js
+++ b/src/messaging.js
@@ -359,7 +359,7 @@ var async = require('async'),
if (parseInt(meta.config.disableChat) === 1 || !uid) {
return callback(new Error('[[error:chat-disabled]]'));
}
-
+
async.waterfall([
function (next) {
Messaging.isUserInRoom(uid, roomId, next);
@@ -368,6 +368,14 @@ var async = require('async'),
if (!inRoom) {
return next(new Error('[[error:not-in-room]]'));
}
+
+ Messaging.getUserCountInRoom(roomId, next);
+ },
+ function(count, next) {
+ if (count < 2) {
+ return next(new Error('[[error:no-users-in-room]]'));
+ }
+
user.getUserFields(uid, ['banned', 'email:confirmed'], next);
},
function (userData, next) {