diff --git a/zerver/decorator.py b/zerver/decorator.py index 7c2ac457fa..e4703719dd 100644 --- a/zerver/decorator.py +++ b/zerver/decorator.py @@ -466,7 +466,8 @@ def client_is_exempt_from_rate_limiting(request): # Don't rate limit requests from Django that come from our own servers, # and don't rate-limit dev instances return ((request.client and request.client.name.lower() == 'internal') - and (is_local_addr(request.META['REMOTE_ADDR']) or settings.DEBUG)) + and (is_local_addr(request.META['REMOTE_ADDR']) or + settings.DEBUG_RATE_LIMITING)) def internal_notify_view(view_func): # type: (ViewFuncT) -> ViewFuncT diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index c0b10bd43a..09268c1e66 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -263,7 +263,7 @@ class RateLimitTestCase(TestCase): with self.settings(RATE_LIMITING=True): with mock.patch('zerver.decorator.rate_limit_user') as rate_limit_mock: with self.errors_disallowed(): - with self.settings(DEBUG=True): + with self.settings(DEBUG_RATE_LIMITING=True): self.assertEqual(f(req), 'some value') self.assertFalse(rate_limit_mock.called) diff --git a/zproject/settings.py b/zproject/settings.py index 5922a87971..b3799d18af 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -404,6 +404,7 @@ CACHES = { RATE_LIMITING_RULES = [ (60, 100), # 100 requests max every minute ] +DEBUG_RATE_LIMITING = DEBUG ######################################################################## # SECURITY SETTINGS