This commit is contained in:
barisusakli
2015-09-14 17:42:06 -04:00
parent 4aad5b8689
commit 15b667850e
5 changed files with 14 additions and 12 deletions

View File

@@ -28,8 +28,6 @@ var db = require('./database'),
}
Messaging.addMessage = function(fromuid, touid, content, timestamp, callback) {
var uids = sortUids(fromuid, touid);
if (typeof timestamp === 'function') {
callback = timestamp;
timestamp = Date.now();
@@ -37,6 +35,16 @@ var db = require('./database'),
timestamp = timestamp || Date.now();
}
if (!content) {
return callback(new Error('[[error:invalid-chat-message]]'));
}
if (content.length > (meta.config.maximumChatMessageLength || 1000)) {
return callback(new Error('[[error:chat-message-too-long]]'));
}
var uids = sortUids(fromuid, touid);
db.incrObjectField('global', 'nextMid', function(err, mid) {
if (err) {
return callback(err);