mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
refactored get_latest_undeleted_pid to not blindly call getPostsByTid in
order to determine post deletion. (issue #320)
This commit is contained in:
@@ -301,33 +301,16 @@ var RDB = require('./redis.js'),
|
||||
RDB.lrange('tid:' + tid + ':posts', 0, -1, function(err, pids) {
|
||||
if (pids.length === 0) return callback(new Error('no-undeleted-pids-found'));
|
||||
|
||||
console.log(tid, pids);
|
||||
pids.reverse();
|
||||
async.detectSeries(pids, function(pid, next) {
|
||||
RDB.hget('post:' + pid, 'deleted', function(err, deleted) {
|
||||
if (deleted === '1') next(true);
|
||||
if (deleted === '0') next(true);
|
||||
else next(false);
|
||||
});
|
||||
}, function(pid) {
|
||||
// console.log(pid);
|
||||
if (pid) callback(null, pid);
|
||||
else callback(new Error('no-undeleted-pids-found'));
|
||||
});
|
||||
});
|
||||
// posts.getPostsByTid(tid, 0, -1, function(posts) {
|
||||
// var numPosts = posts.length;
|
||||
// if (!numPosts)
|
||||
// return callback(new Error('no-undeleted-pids-found'));
|
||||
|
||||
// while (numPosts--) {
|
||||
// if (posts[numPosts].deleted !== '1') {
|
||||
// console.log(posts[numPosts].pid);
|
||||
// callback(null, posts[numPosts].pid);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// callback(new Error('no-undeleted-pids-found'));
|
||||
// });
|
||||
}
|
||||
}(exports));
|
||||
Reference in New Issue
Block a user