Skip to content

Node.js based forum software built for the modern web

limit topic views by session

barisusaklid9b6a06714ac
diff --git a/src/controllers/topics.js b/src/controllers/topics.js
index d3cd6140e7..b738e996eb 100644
--- a/src/controllers/topics.js
+++ b/src/controllers/topics.js
@@ -266,7 +266,11 @@ topicsController.get = function(req, res, callback) {
res.locals.linkTags.push(rel);
});
- topics.increaseViewCount(tid);
+ req.session.tids_viewed = req.session.tids_viewed || {};
+ if (!req.session.tids_viewed[tid] || req.session.tids_viewed[tid] < Date.now() - 3600000) {
+ topics.increaseViewCount(tid);
+ req.session.tids_viewed[tid] = Date.now();
+ }
if (req.uid) {
topics.markAsRead([tid], req.uid, function(err, markedRead) {