Skip to content

Node.js based forum software built for the modern web

feat: add relevant topic events to post objects

Barış Soner Uşaklıa584dae65027
diff --git a/public/src/modules/helpers.common.js b/public/src/modules/helpers.common.js
index 25907fb446..04ab16c3f8 100644
--- a/public/src/modules/helpers.common.js
+++ b/public/src/modules/helpers.common.js
@@ -181,6 +181,7 @@ module.exports = function (utils, Benchpress, relative_path) {
}
function renderTopicEvents(index, sort) {
+ console.warn('[renderTopicEvents] deprecated, use a partial at partials/topic/event.tpl');
if (sort === 'most_votes') {
return '';
}
diff --git a/src/topics/index.js b/src/topics/index.js
index 94f9803f5c..b6dd08e817 100644
--- a/src/topics/index.js
+++ b/src/topics/index.js
@@ -185,6 +185,12 @@ Topics.getTopicWithPosts = async function (topicData, set, uid, start, stop, rev
topicData.thumbs = thumbs[0];
topicData.posts = posts;
topicData.events = events;
+ topicData.posts.forEach((p) => {
+ p.events = events.filter(
+ event => event.timestamp >= p.eventStart && event.timestamp < p.eventEnd
+ );
+ });
+
topicData.category = category;
topicData.tagWhitelist = tagWhitelist[0];
topicData.minTags = category.minTags;