mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-30 19:43:47 +00:00 
			
		
		
		
	rate_limit: Remove rate_limit_ip.
Because rate_limit_request_by_ip is the only caller of it, it is safe for us to inline RateLimitedIpAddr and remove this helper. This ensures that we have consistent internals for rate limiting functions, which all have a should_rate_limit check. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
		
				
					committed by
					
						 Tim Abbott
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							730d3ec929
						
					
				
				
					commit
					de22b72670
				
			| @@ -588,10 +588,6 @@ def rate_limit_user(request: HttpRequest, user: UserProfile, domain: str) -> Non | ||||
|     RateLimitedUser(user, domain=domain).rate_limit_request(request) | ||||
|  | ||||
|  | ||||
| def rate_limit_ip(request: HttpRequest, ip_addr: str, domain: str) -> None: | ||||
|     RateLimitedIPAddr(ip_addr, domain=domain).rate_limit_request(request) | ||||
|  | ||||
|  | ||||
| def rate_limit_request_by_ip(request: HttpRequest, domain: str) -> None: | ||||
|     if not should_rate_limit(request): | ||||
|         return | ||||
| @@ -619,7 +615,7 @@ def rate_limit_request_by_ip(request: HttpRequest, domain: str) -> None: | ||||
|         # service doesn't silently remove this functionality. | ||||
|         logger.warning("Failed to fetch TOR exit node list: %s", err) | ||||
|         pass | ||||
|     rate_limit_ip(request, ip_addr, domain=domain) | ||||
|     RateLimitedIPAddr(ip_addr, domain=domain).rate_limit_request(request) | ||||
|  | ||||
|  | ||||
| def should_rate_limit(request: HttpRequest) -> bool: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user