From f71c82f65347d698bf03efcce2bb32a6d3e4f230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 17 Apr 2015 12:32:00 -0400 Subject: [PATCH] closes #3046 --- src/search.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/search.js b/src/search.js index a0c156535a..a2bb96a33f 100644 --- a/src/search.js +++ b/src/search.js @@ -149,8 +149,8 @@ function filterAndSort(pids, data, callback) { } function getMatchedPosts(pids, data, callback) { - var postFields = ['pid', 'tid', 'timestamp']; - var topicFields = []; + var postFields = ['pid', 'tid', 'timestamp', 'deleted']; + var topicFields = ['deleted']; var categoryFields = []; if (data.replies) { @@ -180,7 +180,9 @@ function getMatchedPosts(pids, data, callback) { db.getObjectsFields(keys, postFields, next); }, function(_posts, next) { - posts = _posts; + posts = _posts.filter(function(post) { + return post && parseInt(post.deleted, 10) !== 1; + }); async.parallel({ users: function(next) { @@ -194,10 +196,6 @@ function getMatchedPosts(pids, data, callback) { } }, topics: function(next) { - if (!topicFields.length) { - return next(); - } - var topics; async.waterfall([ function(next) { @@ -268,6 +266,10 @@ function getMatchedPosts(pids, data, callback) { } }); + posts = posts.filter(function(post) { + return post && post.topic && parseInt(post.topic.deleted, 10) !== 1; + }); + next(null, posts); } ], callback);