mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
better filterIgnoringUids
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user