refactor: organize import statements for clarity and consistency

This commit is contained in:
Siddhant Rai
2025-10-03 12:41:03 +05:30
parent 70183e234a
commit 6c43245295
6 changed files with 9 additions and 37 deletions

View File

@@ -1,6 +1,8 @@
"""Agent management routes."""
import datetime, json, uuid
import datetime
import json
import uuid
from bson.dbref import DBRef
from bson.objectid import ObjectId

View File

@@ -1,6 +1,7 @@
"""Agent management sharing functionality."""
import datetime, secrets
import datetime
import secrets
from bson import DBRef
from bson.objectid import ObjectId

View File

@@ -1,7 +1,6 @@
"""Agent management webhook handlers."""
import secrets
from functools import wraps
from bson.objectid import ObjectId
from flask import current_app, jsonify, make_response, request
@@ -64,31 +63,6 @@ class AgentWebhook(Resource):
)
def require_agent(func):
@wraps(func)
def wrapper(*args, **kwargs):
webhook_token = kwargs.get("webhook_token")
if not webhook_token:
return make_response(
jsonify({"success": False, "message": "Webhook token missing"}), 400
)
agent = agents_collection.find_one(
{"incoming_webhook_token": webhook_token}, {"_id": 1}
)
if not agent:
current_app.logger.warning(
f"Webhook attempt with invalid token: {webhook_token}"
)
return make_response(
jsonify({"success": False, "message": "Agent not found"}), 404
)
kwargs["agent"] = agent
kwargs["agent_id_str"] = str(agent["_id"])
return func(*args, **kwargs)
return wrapper
@agents_webhooks_ns.route("/webhooks/agents/<string:webhook_token>")
class AgentWebhookListener(Resource):
method_decorators = [require_agent]