fix: crash if post doesn't have topic data

v1.18.x
Barış Soner Uşaklı 5 years ago
parent e52ecfaf3f
commit eabc6f4763

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

Loading…
Cancel
Save