|
|
@ -8,10 +8,16 @@ var sockets = require('../socket.io');
|
|
|
|
module.exports = function(Messaging) {
|
|
|
|
module.exports = function(Messaging) {
|
|
|
|
|
|
|
|
|
|
|
|
Messaging.getUnreadCount = function(uid, callback) {
|
|
|
|
Messaging.getUnreadCount = function(uid, callback) {
|
|
|
|
|
|
|
|
if (!parseInt(uid, 10)) {
|
|
|
|
|
|
|
|
return callback(null, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
db.sortedSetCard('uid:' + uid + ':chat:rooms:unread', callback);
|
|
|
|
db.sortedSetCard('uid:' + uid + ':chat:rooms:unread', callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Messaging.pushUnreadCount = function(uid) {
|
|
|
|
Messaging.pushUnreadCount = function(uid) {
|
|
|
|
|
|
|
|
if (!parseInt(uid, 10)) {
|
|
|
|
|
|
|
|
return callback(null, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
Messaging.getUnreadCount(uid, function(err, unreadCount) {
|
|
|
|
Messaging.getUnreadCount(uid, function(err, unreadCount) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -24,6 +30,10 @@ module.exports = function(Messaging) {
|
|
|
|
db.sortedSetRemove('uid:' + uid + ':chat:rooms:unread', roomId, callback);
|
|
|
|
db.sortedSetRemove('uid:' + uid + ':chat:rooms:unread', roomId, callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Messaging.markAllRead = function(uid, callback) {
|
|
|
|
|
|
|
|
db.delete('uid:' + uid + ':chat:rooms:unread', callback);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Messaging.markUnread = function(uids, roomId, callback) {
|
|
|
|
Messaging.markUnread = function(uids, roomId, callback) {
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|