From 69b02b363ec19a5311d3687a51e690d3550e19d1 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 24 May 2025 18:27:09 -0400 Subject: [PATCH] Fix bug when checking if token is in use and added the token to the active clients when selected --- app/internal/types.py | 4 ++-- app/routers/bot.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/internal/types.py b/app/internal/types.py index a1d7346..2dc464d 100644 --- a/app/internal/types.py +++ b/app/internal/types.py @@ -6,9 +6,9 @@ class ActiveClient: The active client model in memory for quicker access """ websocket = None - active_token: str = None + active_token: DiscordId = None - def __init__(self, websocket= None, active_token:str=None): + def __init__(self, websocket= None, active_token:DiscordId=None): self.active_token = active_token self.websocket = websocket diff --git a/app/routers/bot.py b/app/routers/bot.py index 8e5d78a..84bc3c7 100644 --- a/app/routers/bot.py +++ b/app/routers/bot.py @@ -46,6 +46,7 @@ async def request_token_route(): # --- Logic for selecting a preferred ID based on client_id (TODO) --- selected_id = avail_ids[0] + current_app.active_clients[client_id].active_token = selected_id # --- End of logic for selecting a preferred ID --- @@ -67,8 +68,8 @@ def find_token_in_active_clients(target_token: str) -> bool: Returns: True if the token is found in any ActiveClient, False otherwise. """ - for client in current_app.active_clients: - if client.active_token == target_token: + for client_id in current_app.active_clients: + if current_app.active_clients[client_id].active_token == target_token: return True return False