From fb355272fce0a219d4f31ea5cc601ed72445d873 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Fri, 6 Dec 2013 15:21:32 -0600 Subject: [PATCH] Fix #316 --- lib/user.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/user.js b/lib/user.js index 696e9391..1334ab32 100644 --- a/lib/user.js +++ b/lib/user.js @@ -36,6 +36,7 @@ var User = function (socket) { }; this.queueLimiter = $util.newRateLimiter(); this.chatLimiter = $util.newRateLimiter(); + this.rankListLimiter = $util.newRateLimiter(); this.profile = { image: "", text: "" @@ -460,9 +461,18 @@ User.prototype.initCallbacks = function () { self.socket.on("requestChannelRanks", function () { if (self.inChannel()) { - if (self.noflood("requestChannelRanks", 0.25)) - return; - self.channel.sendChannelRanks(self); + if (self.rankListLimiter.throttle({ + burst: 0, + sustained: 0.1, + cooldown: 10 + })) { + self.socket.emit("noflood", { + action: "channel ranks", + msg: "You may only refresh channel ranks once every 10 seconds" + }); + } else { + self.channel.sendChannelRanks(self); + } } });