mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
check if user exists
This commit is contained in:
@@ -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();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user