FreeFeed / freefeed-server

FreeFeed server
https://freefeed.net
MIT License
41 stars 18 forks source link

Make sure we remember about blocking people for longer than they are blocked #620

Closed n1313 closed 1 year ago

n1313 commented 1 year ago

This PR fixes a problem in incremental blocking by rate limiter, where after a certain point the block time (which would grow with each subsequent block) would be longer than the TTL of the "how many times was this client blocked previously" counter (which is always 10 minutes). With this change we remember about previous blocks for 10 minutes plus the time of the actual block.

Also added some descriptive comments and improved variable names to make the code more readable.

davidmz commented 1 year ago

А ты не хочешь придумать какой-то способ тестирования этого?

n1313 commented 1 year ago

Интеграционный с настоящим редисом может быть немного сложно (и относительно долго будет исполняться), а юнит, если всё замокать, можно попробовать, да.