Fix bug when checking if token is in use and added the token to the active clients when selected
This commit is contained in:
@@ -6,9 +6,9 @@ class ActiveClient:
|
|||||||
The active client model in memory for quicker access
|
The active client model in memory for quicker access
|
||||||
"""
|
"""
|
||||||
websocket = None
|
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.active_token = active_token
|
||||||
self.websocket = websocket
|
self.websocket = websocket
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ async def request_token_route():
|
|||||||
# --- Logic for selecting a preferred ID based on client_id (TODO) ---
|
# --- Logic for selecting a preferred ID based on client_id (TODO) ---
|
||||||
|
|
||||||
selected_id = avail_ids[0]
|
selected_id = avail_ids[0]
|
||||||
|
current_app.active_clients[client_id].active_token = selected_id
|
||||||
|
|
||||||
# --- End of logic for selecting a preferred ID ---
|
# --- End of logic for selecting a preferred ID ---
|
||||||
|
|
||||||
@@ -67,8 +68,8 @@ def find_token_in_active_clients(target_token: str) -> bool:
|
|||||||
Returns:
|
Returns:
|
||||||
True if the token is found in any ActiveClient, False otherwise.
|
True if the token is found in any ActiveClient, False otherwise.
|
||||||
"""
|
"""
|
||||||
for client in current_app.active_clients:
|
for client_id in current_app.active_clients:
|
||||||
if client.active_token == target_token:
|
if current_app.active_clients[client_id].active_token == target_token:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user