better filterIgnoringUids

v1.18.x
barisusakli 9 years ago
parent a141f6f7ec
commit 7a044b4978

@ -312,17 +312,12 @@ var privileges = require('./privileges');
Categories.filterIgnoringUids = function(cid, uids, callback) {
async.waterfall([
function (next){
Categories.getIgnorers(cid, 0, -1, next);
db.sortedSetScores('cid:' + cid + ':ignorers', uids, next);
},
function (ignorerUids, next){
if (!ignorerUids.length) {
return next(null, uids);
}
var readingUids = uids.filter(function(uid) {
return ignorerUids.indexOf(uid.toString()) === -1;
function (scores, next) {
var readingUids = uids.filter(function(uid, index) {
return uid && !!scores[index];
});
next(null, readingUids);
}
], callback);

@ -181,20 +181,15 @@ module.exports = function(Topics) {
db.getSetMembers('tid:' + tid + ':ignorers', callback);
};
Topics.filterIgnoringUids = function(tid, uids, callback){
Topics.filterIgnoringUids = function(tid, uids, callback) {
async.waterfall([
function (next){
Topics.getIgnorers(tid, next);
db.isSetMembers('tid:' + tid + ':ignorers', uids, next);
},
function (ignorerUids, next){
if (!ignorerUids.length) {
return next(null, uids);
}
var readingUids = uids.filter(function(uid) {
return ignorerUids.indexOf(uid.toString()) === -1;
function (isMembers, next){
var readingUids = uids.filter(function(uid, index) {
return uid && isMembers[index];
});
next(null, readingUids);
}
], callback);

Loading…
Cancel
Save