Node.js based forum software built for the modern web
interim commit
Julian Lam2b7fd3c9d179
diff --git a/src/threadTools.js b/src/threadTools.jsindex d4c9ab682b..83925dcd2a 100644--- a/src/threadTools.js+++ b/src/threadTools.js@@ -298,21 +298,36 @@ var RDB = require('./redis.js'),}ThreadTools.get_latest_undeleted_pid = function(tid, callback) {-- 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'));+ 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);+ 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));\ No newline at end of file