add label to banned users, dont hide their posts

This commit is contained in:
Baris Soner Usakli
2013-08-14 17:42:36 -04:00
parent 74af205426
commit 999e98e43d
8 changed files with 29 additions and 59 deletions

View File

@@ -291,32 +291,14 @@ var RDB = require('./redis.js'),
if(!numPosts)
return callback(new Error('no-undeleted-pids-found'));
posts = posts.reverse();
lastPostId = 0;
function isPostVisible(post, next) {
if(post.deleted !== '1') {
user.getUserField(post.uid, 'banned', function(banned) {
if(banned && banned === '1') {
next(null);
} else {
lastPostId = post.pid
next(post.pid);
return;
}
});
} else {
next(null);
while(numPosts--) {
if(posts[numPosts].deleted !== '1') {
callback(null, posts[numPosts].pid);
return;
}
}
async.eachSeries(posts, isPostVisible, function(err) {
if(err) {
callback(null, lastPostId);
} else {
callback(new Error('no-undeleted-pids-found'));
}
});
callback(new Error('no-undeleted-pids-found'));
});
}
}(exports));