|
|
|
@ -1017,26 +1017,30 @@ var bcrypt = require('bcryptjs'),
|
|
|
|
|
|
|
|
|
|
async.parallel({
|
|
|
|
|
unread: function(next) {
|
|
|
|
|
getNotifications('uid:' + uid + ':notifications:unread', 0, 10, function(notif_data) {
|
|
|
|
|
getNotifications('uid:' + uid + ':notifications:unread', 0, 9, function(notif_data) {
|
|
|
|
|
notif_data.readClass = !notif_data.read ? 'label-warning' : '';
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
read: function(next) {
|
|
|
|
|
getNotifications('uid:' + uid + 'notifications:read', 0, 10, null, next);
|
|
|
|
|
getNotifications('uid:' + uid + ':notifications:read', 0, 9, null, next);
|
|
|
|
|
}
|
|
|
|
|
}, function(err, notifications) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return calback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Limit the number of notifications to `maxNotifs`, prioritising unread notifications
|
|
|
|
|
if (notifications.read.length + notifications.unread.length > maxNotifs) {
|
|
|
|
|
notifications.read.length = maxNotifs - notifications.unread.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callback(err, notifications);
|
|
|
|
|
callback(null, notifications);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
getAll: function(uid, limit, before, callback) {
|
|
|
|
|
var now = new Date();
|
|
|
|
|
|
|
|
|
|
if (!limit || parseInt(limit,10) <= 0) {
|
|
|
|
|
if (!limit || parseInt(limit, 10) <= 0) {
|
|
|
|
|
limit = 25;
|
|
|
|
|
}
|
|
|
|
|
if (before) {
|
|
|
|
|