Skip to content

Commit

Permalink
Setting default rate limits for chatconsumer
Browse files Browse the repository at this point in the history
jamesrichards4 committed Jan 29, 2025
1 parent b92513f commit 8c167b3
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion django_app/redbox_app/redbox_core/consumers.py
Original file line number Diff line number Diff line change
@@ -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."""
2 changes: 1 addition & 1 deletion django_app/redbox_app/redbox_core/ratelimit.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8c167b3

Please sign in to comment.