mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
fixed bug where deleted posts still showed up in teasers
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user