From db291ecde11acac6671e551a3855b6e9e52cc86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 13 Nov 2024 18:38:36 -0500 Subject: [PATCH] fix: filter undefined posts/topics --- src/topics/scheduled.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/topics/scheduled.js b/src/topics/scheduled.js index 129f4113f3..9bf325231a 100644 --- a/src/topics/scheduled.js +++ b/src/topics/scheduled.js @@ -111,7 +111,9 @@ async function sendNotifications(uids, topicsData) { const userData = await user.getUsersData(uids); const uidToUserData = Object.fromEntries(uids.map((uid, idx) => [uid, userData[idx]])); - const postsData = await posts.getPostsData(topicsData.map(t => t && t.mainPid)); + let postsData = await posts.getPostsData(topicsData.map(t => t && t.mainPid)); + topicsData = topicsData.filter((t, i) => t && postsData[i]); + postsData = postsData.filter(Boolean); postsData.forEach((postData, idx) => { if (postData) { postData.user = uidToUserData[topicsData[idx].uid];