fixed bug where deleted posts still showed up in teasers

v1.18.x
Julian Lam 12 years ago
parent 47d491b266
commit 7c165876f1

@ -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',

@ -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);
});
});

Loading…
Cancel
Save