mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
final pass, #999
This commit is contained in:
@@ -19,18 +19,37 @@ var async = require('async'),
|
||||
Notifications.get = function(nid, uid, callback) {
|
||||
|
||||
db.exists('notifications:' + nid, function(err, exists) {
|
||||
if(!exists) {
|
||||
if (err) {
|
||||
winston.error('[notifications.get] Could not retrieve nid ' + nid + ': ' + err.message);
|
||||
return callback(null);
|
||||
}
|
||||
|
||||
db.sortedSetRank('uid:' + uid + ':notifications:read', nid, function(err, rank) {
|
||||
if (exists) {
|
||||
db.sortedSetRank('uid:' + uid + ':notifications:read', nid, function(err, rank) {
|
||||
|
||||
db.getObjectFields('notifications:' + nid, ['nid', 'text', 'score', 'path', 'datetime', 'uniqueId'], function(err, notification) {
|
||||
db.getObjectFields('notifications:' + nid, ['nid', 'text', 'score', 'path', 'datetime', 'uniqueId'], function(err, notification) {
|
||||
|
||||
notification.read = rank !== null ? true:false;
|
||||
callback(notification);
|
||||
notification.read = rank !== null ? true:false;
|
||||
callback(notification);
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// Remove from the user's boxes
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
winston.info('[notifications.get] nid ' + nid + ' not found. Removing.');
|
||||
}
|
||||
|
||||
async.parallel([
|
||||
function(next) {
|
||||
db.sortedSetRemove('uid:' + uid + ':notifications:unread', nid, next);
|
||||
},
|
||||
function(next) {
|
||||
db.sortedSetRemove('uid:' + uid + ':notifications:read', nid, next);
|
||||
}
|
||||
], function(err) {
|
||||
callback(null);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user