Node.js based forum software built for the modern web
fixed bug where deleted posts still showed up in teasers
Julian Lam7c165876f15d
diff --git a/src/topics.js b/src/topics.jsindex b6afa9e93b..75618dc453 100644--- a/src/topics.js+++ b/src/topics.js@@ -285,8 +285,26 @@ marked.setOptions({} else callback([]);}+ Topics.get_latest_undeleted_pid = function(tid, callback) {+ RDB.lrange('tid:' + tid + ':posts', 0, -1, function(err, pids) {+ var pidKeys = [];+ for(var x=0,numPids=pids.length;x<numPids;x++) {+ pidKeys.push('pid:' + pids[x] + ':deleted');+ }+ RDB.mget(pidKeys, function(err, posts) {+ var numPosts = posts.length;+ while(numPosts--) {+ if (posts[numPosts] !== '1') {+ callback(pids[numPosts]);+ break;+ }+ }+ });+ });+ }+Topics.get_teaser = function(tid, callback) {- RDB.lrange('tid:' + tid + ':posts', -1, -1, function(err, pid) {+ Topics.get_latest_undeleted_pid(tid, function(pid) {if (pid !== null) {RDB.mget(['pid:' + pid + ':content',diff --git a/src/webserver.js b/src/webserver.jsindex 6c51153768..b9a7269a1f 100644--- a/src/webserver.js+++ b/src/webserver.js@@ -237,8 +237,8 @@ var express = require('express'),app.get('/api/:method/:id*', api_method);app.get('/test', function(req, res) {- topics.get_topic(3, 1, function(data) {- res.send(JSON.stringify(data));+ topics.get_latest_undeleted_pid(5, function(pid) {+ res.send(pid);});});