Fixed bug where updates on sliders weren't debounced

This commit is contained in:
Stefan Zermatten
2022-11-19 22:39:35 +02:00
parent cc915410da
commit 04c9c4cfc2
3 changed files with 296 additions and 283 deletions

View File

@@ -0,0 +1,16 @@
const logRateLimit = _.debounce(function (ruleInput) {
console.log(`Rate limit on ${ruleInput.name} by user ${ruleInput.userId} at IP ${ruleInput.clientAddress}`);
}, 500);
DDPRateLimiter.addRule({
type: 'method',
name(name) {
return true;
},
// Rate limit per connection ID
connectionId() { return true; }
}, 10, 1000, (reply, ruleInput) => {
if (!reply.allowed) {
logRateLimit(ruleInput);
}
});