|
|
@ -39,6 +39,20 @@ var async = require('async'),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserNotifications.getAll = function(uid, count, callback) {
|
|
|
|
|
|
|
|
getNotifications(uid, count, function(err, notifs) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return callback(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
notifs = notifs.unread.concat(notifs.read);
|
|
|
|
|
|
|
|
notifs = notifs.filter(Boolean).sort(function(a, b) {
|
|
|
|
|
|
|
|
return b.datetime - a.datetime;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback(null, notifs);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function getNotifications(uid, count, callback) {
|
|
|
|
function getNotifications(uid, count, callback) {
|
|
|
|
async.parallel({
|
|
|
|
async.parallel({
|
|
|
|
unread: function(next) {
|
|
|
|
unread: function(next) {
|
|
|
|