Compare commits

..

2 Commits

Author SHA1 Message Date
Logan Cusano
4a61bd195f Added new node route to get online bots 2025-05-24 23:24:18 -04:00
Logan Cusano
fbd0e65019 Minor bugs when creating a system 2025-05-24 22:44:20 -04:00
3 changed files with 12 additions and 3 deletions

View File

@@ -33,7 +33,7 @@ class SystemDbController():
try: try:
# Check if the data to be inserted has an ID # Check if the data to be inserted has an ID
if not system_data.get("_id"): if not system_data.get("_id"):
system_data['_id'] = uuid4() system_data['_id'] = str(uuid4())
inserted_result = None inserted_result = None
inserted_id = None inserted_id = None

View File

@@ -112,4 +112,13 @@ async def leave():
return jsonify({"status": "command sent", "client_id": client_id, "command": NodeCommands.LEAVE}), 200 return jsonify({"status": "command sent", "client_id": client_id, "command": NodeCommands.LEAVE}), 200
except Exception as e: except Exception as e:
return jsonify({"error": f"Failed to send command: {e}"}), 500 return jsonify({"error": f"Failed to send command: {e}"}), 500
@nodes_bp.route("/get_online_bots", methods=['GET'])
async def get_online_bots():
active_bots = []
for client in current_app.active_clients:
active_bots.append(client.active_token.to_dict())
return jsonify(active_bots)

View File

@@ -38,7 +38,7 @@ async def create_system_route():
if created_system: if created_system:
print("Created new system:", created_system) print("Created new system:", created_system)
return jsonify(created_system), 201 return jsonify(created_system.to_dict()), 201
else: else:
abort(500, "Failed to create system in the database.") abort(500, "Failed to create system in the database.")
except HTTPException: except HTTPException: