From eabc6f4763b808ed5a20af2634747bdd6c4cb3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 8 Nov 2019 18:38:58 -0500 Subject: [PATCH] fix: crash if post doesn't have topic data --- src/posts/category.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posts/category.js b/src/posts/category.js index c84fe73007..8ca44b4145 100644 --- a/src/posts/category.js +++ b/src/posts/category.js @@ -18,7 +18,7 @@ module.exports = function (Posts) { const tids = _.uniq(postData.map(post => post && post.tid).filter(Boolean)); const topicData = await topics.getTopicsFields(tids, ['cid']); const tidToTopic = _.zipObject(tids, topicData); - const cids = postData.map(post => tidToTopic[post.tid].cid); + const cids = postData.map(post => tidToTopic[post.tid] && tidToTopic[post.tid].cid); return cids; };