mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 12:36:02 +01:00
interim commit
This commit is contained in:
@@ -298,21 +298,36 @@ var RDB = require('./redis.js'),
|
||||
}
|
||||
|
||||
ThreadTools.get_latest_undeleted_pid = function(tid, callback) {
|
||||
RDB.lrange('tid:' + tid + ':posts', 0, -1, function(err, pids) {
|
||||
if (pids.length === 0) return 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') {
|
||||
callback(null, posts[numPosts].pid);
|
||||
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);
|
||||
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