From 22811dd3a687c16ec30556eb31a680447ba41e91 Mon Sep 17 00:00:00 2001 From: Samuel Olwe Date: Fri, 20 Dec 2024 20:38:15 +0300 Subject: [PATCH] chore: update comments --- webapp/decorators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/decorators.py b/webapp/decorators.py index e27f48be20a..9a882a584fc 100644 --- a/webapp/decorators.py +++ b/webapp/decorators.py @@ -59,7 +59,7 @@ def rate_limited(*args, **kwargs): try: # Get the initial request initial_request = json.loads(flask.session[func.__name__]) - # Get the current limit + # Get the seconds limit for these attempts seconds_limit = rate_limit_attempt_map.get(request_limit) for limit in sorted(rate_limit_attempt_map.keys()): seconds_limit = rate_limit_attempt_map.get(limit) @@ -72,13 +72,13 @@ def rate_limited(*args, **kwargs): # Abort if the time is too early for this number of attempts # Or if the max number of attempts has been exceeded if initial_request["attempts"] >= request_limit: - # Reset the timer if we have exceeded the limit if ( time_since_last_request.total_seconds() < seconds_limit.total_seconds() ): return flask.abort(429) else: + # Reset the timer if we have exceeded the limit initial_request["timestamp"] = datetime.now() # Otherwise update the session