fix: topic events if there is a blocked user in topic

This commit is contained in:
Barış Soner Uşaklı
2022-03-16 16:56:07 -04:00
parent 2808c952c5
commit 3935a86b83

View File

@@ -55,8 +55,18 @@ module.exports = function (Topics) {
}
Topics.calculatePostIndices(replies, repliesStart);
postData = await user.blocks.filter(uid, postData);
await addEventStartEnd(postData, set, reverse, topicData);
const allPosts = postData.slice();
postData = await user.blocks.filter(uid, postData);
if (allPosts.length !== postData.length) {
const includedPids = new Set(postData.map(p => p.pid));
allPosts.reverse().forEach((p, index) => {
if (!includedPids.has(p.pid) && allPosts[index + 1] && !reverse) {
allPosts[index + 1].eventEnd = p.eventEnd;
}
});
}
const result = await plugins.hooks.fire('filter:topic.getPosts', {
topic: topicData,
uid: uid,