mirror of
https://github.com/zulip/zulip.git
synced 2026-07-03 21:10:12 +08:00
rate_limit: Extract should_rate_limit from rate_limit.
This allows us to reapply this check for other rate limiting functions. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
parent
6e725fb3c3
commit
79e86471e7
@ -632,11 +632,18 @@ def rate_limit_remote_server(
|
||||
raise e
|
||||
|
||||
|
||||
def rate_limit(request: HttpRequest) -> None:
|
||||
def should_rate_limit(request: HttpRequest) -> bool:
|
||||
if not settings.RATE_LIMITING:
|
||||
return
|
||||
return False
|
||||
|
||||
if client_is_exempt_from_rate_limiting(request):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def rate_limit(request: HttpRequest) -> None:
|
||||
if not should_rate_limit(request):
|
||||
return
|
||||
|
||||
from zerver.lib.request import RequestNotes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user