From d9b6a06714ace68ef090323fb4223ac0a4c93059 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 3 Jan 2016 14:37:37 +0200 Subject: [PATCH] limit topic views by session --- src/controllers/topics.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) {