diff --git a/src/topics/scheduled.js b/src/topics/scheduled.js index 5b98bea84f..129f4113f3 100644 --- a/src/topics/scheduled.js +++ b/src/topics/scheduled.js @@ -48,7 +48,7 @@ async function postTids(tids) { await Promise.all([].concat( sendNotifications(uids, topicsData), updateUserLastposttimes(uids, topicsData), - updateGroupPosts(uids, topicsData), + updateGroupPosts(topicsData), ...topicsData.map(topicData => unpin(topicData.tid, topicData)), )); } @@ -151,10 +151,10 @@ async function updateUserLastposttimes(uids, topicsData) { return Promise.all(uidsToUpdate.map(uid => user.setUserField(uid, 'lastposttime', tstampByUid[uid]))); } -async function updateGroupPosts(uids, topicsData) { +async function updateGroupPosts(topicsData) { const postsData = await posts.getPostsData(topicsData.map(t => t && t.mainPid)); await Promise.all(postsData.map(async (post, i) => { - if (topicsData[i]) { + if (post && topicsData[i]) { post.cid = topicsData[i].cid; await groups.onNewPostMade(post); }