|
|
|
@ -76,7 +76,7 @@ var db = require('./database'),
|
|
|
|
|
async.apply(Messaging.updateChatTime, touid, fromuid),
|
|
|
|
|
async.apply(Messaging.markRead, fromuid, touid),
|
|
|
|
|
async.apply(Messaging.markUnread, touid, fromuid),
|
|
|
|
|
], function(err, results) {
|
|
|
|
|
], function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
@ -365,29 +365,29 @@ var db = require('./database'),
|
|
|
|
|
return callback(new Error('[[error:chat-disabled]]'));
|
|
|
|
|
} else if (toUid === fromUid) {
|
|
|
|
|
return callback(new Error('[[error:cant-chat-with-yourself]]'));
|
|
|
|
|
} else if (fromUid === 0) {
|
|
|
|
|
} else if (!fromUid) {
|
|
|
|
|
return callback(new Error('[[error:not-logged-in]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function (next) {
|
|
|
|
|
user.getUserFields(fromUid, ['banned', 'email:confirmed'], function(err, userData) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
user.exists(toUid, next);
|
|
|
|
|
},
|
|
|
|
|
function (exists, next) {
|
|
|
|
|
if (!exists) {
|
|
|
|
|
return next(new Error('[[error:no-user]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
user.getUserFields(fromUid, ['banned', 'email:confirmed'], next);
|
|
|
|
|
},
|
|
|
|
|
function (userData, next) {
|
|
|
|
|
if (parseInt(userData.banned, 10) === 1) {
|
|
|
|
|
return callback(new Error('[[error:user-banned]]'));
|
|
|
|
|
return next(new Error('[[error:user-banned]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (parseInt(meta.config.requireEmailConfirmation, 10) === 1 && parseInt(userData['email:confirmed'], 10) !== 1) {
|
|
|
|
|
return callback(new Error('[[error:email-not-confirmed-chat]]'));
|
|
|
|
|
return next(new Error('[[error:email-not-confirmed-chat]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
next();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
user.getSettings(toUid, next);
|
|
|
|
|
},
|
|
|
|
|
function(settings, next) {
|
|
|
|
|