From 8c167b35cd7ea3115c9f9a33b54254b8da30ae3b Mon Sep 17 00:00:00 2001 From: jamesrichards Date: Wed, 29 Jan 2025 11:27:38 +0000 Subject: [PATCH] Setting default rate limits for chatconsumer --- django_app/redbox_app/redbox_core/consumers.py | 3 ++- django_app/redbox_app/redbox_core/ratelimit.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/django_app/redbox_app/redbox_core/consumers.py b/django_app/redbox_app/redbox_core/consumers.py index bf1d3316c..e31607d3d 100644 --- a/django_app/redbox_app/redbox_core/consumers.py +++ b/django_app/redbox_app/redbox_core/consumers.py @@ -25,6 +25,7 @@ ChatMessage, File, ) +from redbox.models.settings import get_settings from redbox_app.redbox_core.ratelimit import UserRateLimiter from redbox_app.redbox_core.utils import sanitise_string @@ -48,7 +49,7 @@ class ChatConsumer(AsyncWebsocketConsumer): full_reply: ClassVar = [] route = None redbox = Redbox(debug=settings.DEBUG) - user_ratelimiter: UserRateLimiter = UserRateLimiter() + user_ratelimiter: UserRateLimiter = UserRateLimiter(initial_user_credits=get_settings().user_token_rate_limit_second*60) async def receive(self, text_data=None, bytes_data=None): """Receive & respond to message from browser websocket.""" diff --git a/django_app/redbox_app/redbox_core/ratelimit.py b/django_app/redbox_app/redbox_core/ratelimit.py index d5a3daea2..5073060b8 100644 --- a/django_app/redbox_app/redbox_core/ratelimit.py +++ b/django_app/redbox_app/redbox_core/ratelimit.py @@ -23,7 +23,7 @@ class UserRateLimiter(): def __init__( self, - initial_user_credits = 350_000 + initial_user_credits = 360_000 ) -> None: self.initial_user_credits = initial_user_credits