Update token CRUD endpoints to use ObjectId for IDs
All checks were successful
release-image / release-image (push) Successful in 2m3s

This commit is contained in:
Logan Cusano
2025-06-29 21:35:11 -04:00
parent 64e3031389
commit da173e7f58

View File

@@ -5,6 +5,7 @@ from internal.types import ActiveClient, DiscordId, UserRoles
from internal.db_wrappers import DiscordIdDbController
from quart_jwt_extended import jwt_required
from routers.auth import role_required
from bson.objectid import ObjectId
bot_bp = Blueprint('bot', __name__)
@@ -87,7 +88,7 @@ async def get_discord_token_by_id(discord_id_param: str):
API endpoint to get a single Discord ID by its _id.
"""
try:
query = {"_id": discord_id_param}
query = {"_id": ObjectId(discord_id_param)}
d_id = await current_app.d_id_db_h.find_discord_id(query)
if d_id:
return jsonify(d_id.to_dict())
@@ -108,7 +109,7 @@ async def create_discord_token():
data = await request.get_json()
if '_id' in data:
id_search_result = await current_app.sys_db_h.find_system({"_id": data["_id"]})
id_search_result = await current_app.sys_db_h.find_system({"_id": ObjectId(data["_id"])})
if id_search_result:
# If _id is provided and exists, return conflict
abort(409, f"System with ID '{data['_id']}' already exists")
@@ -148,7 +149,7 @@ async def update_discord_token(discord_id_param: str):
if not data:
abort(400, "No update data provided.")
query = {"_id": discord_id_param}
query = {"_id": ObjectId(discord_id_param)}
update_result = await current_app.d_id_db_h.update_discord_id(query, {"$set": data})
if update_result is not None:
@@ -173,7 +174,7 @@ async def delete_discord_token(discord_id_param: str):
API endpoint to delete a Discord ID by its _id.
"""
try:
query = {"_id": discord_id_param}
query = {"_id": ObjectId(discord_id_param)}
delete_count = await current_app.d_id_db_h.delete_discord_id(query)
if delete_count is not None: