var config = require('../config').config;

// 发帖时间间隔，为毫秒
var POST_INTERVAL = config.post_interval;
if (!(POST_INTERVAL > 0)) POST_INTERVAL = 0;
var DISABLE_POST_INTERVAL = POST_INTERVAL > 0 ? false : true;

/**
 * 发帖/评论时间间隔限制
 */
exports.postInterval = function (req, res, next) {
  if (DISABLE_POST_INTERVAL) return next();
  if (isNaN(req.session.lastPostTimestamp)) {
    req.session.lastPostTimestamp = Date.now();
    return next();
  }
  if (Date.now() - req.session.lastPostTimestamp < POST_INTERVAL) {
    var ERROR_MSG = '您的回复速度太快。';
    if (req.accepts('json')) {
      res.json({error: ERROR_MSG});
    } else {
      res.render('notify/notify', {error: ERROR_MSG});
    }
    return;
  }

  req.session.lastPostTimestamp = Date.now();
  next();
};

@@ -540,90 +540,8 @@
 %E3%80%82';%0A
-    if (req.accepts('json')) %7B%0A      res.json(%7Berror: ERROR_MSG%7D);%0A    %7D else %7B%0A  
     
@@ -593,14 +593,8 @@
 %7D);%0A
-    %7D%0A
     

fix #372