check if user exists

v1.18.x
barisusakli 10 years ago
parent 8e06ff49f3
commit 5cf983dcee

@ -320,7 +320,17 @@ var db = require('./database'),
};
Messaging.markUnread = function(uid, toUid, callback) {
db.sortedSetAdd('uid:' + uid + ':chats:unread', Date.now(), toUid, callback);
async.waterfall([
function (next) {
user.exists(toUid, next);
},
function (exists, next) {
if (!exists) {
return next(new Error('[[error:no-user]]'));
}
db.sortedSetAdd('uid:' + uid + ':chats:unread', Date.now(), toUid, next);
}
], callback);
};
Messaging.notifyUser = function(fromuid, touid, messageObj) {

@ -71,9 +71,12 @@ SocketModules.chats.canMessage = function(socket, toUid, callback) {
SocketModules.chats.markRead = function(socket, touid, callback) {
Messaging.markRead(socket.uid, touid, function(err) {
if (!err) {
Messaging.pushUnreadCount(socket.uid);
if (err) {
return callback(err);
}
Messaging.pushUnreadCount(socket.uid);
callback();
});
};

Loading…
Cancel
Save