diff --git a/src/topics/posts.js b/src/topics/posts.js index de016b8ce1..4a54e571c9 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -38,8 +38,12 @@ module.exports = function(Topics) { Topics.addPostData = function(postData, uid, callback) { var pids = postData.map(function(post) { - return post.pid; - }); + return post && post.pid; + }).filter(Boolean); + + if (!Array.isArray(pids) || !pids.length) { + return callback(null, []); + } async.parallel({ favourites: function(next) {