diff --git a/application/api/user/agents/routes.py b/application/api/user/agents/routes.py index ace1b232..da76f906 100644 --- a/application/api/user/agents/routes.py +++ b/application/api/user/agents/routes.py @@ -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 diff --git a/application/api/user/agents/sharing.py b/application/api/user/agents/sharing.py index 87044564..7c823307 100644 --- a/application/api/user/agents/sharing.py +++ b/application/api/user/agents/sharing.py @@ -1,6 +1,7 @@ """Agent management sharing functionality.""" -import datetime, secrets +import datetime +import secrets from bson import DBRef from bson.objectid import ObjectId diff --git a/application/api/user/agents/webhooks.py b/application/api/user/agents/webhooks.py index 2aacb49e..7fa1398c 100644 --- a/application/api/user/agents/webhooks.py +++ b/application/api/user/agents/webhooks.py @@ -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/") class AgentWebhookListener(Resource): method_decorators = [require_agent] diff --git a/application/api/user/base.py b/application/api/user/base.py index 0d82acc5..ac99b527 100644 --- a/application/api/user/base.py +++ b/application/api/user/base.py @@ -8,7 +8,6 @@ import uuid from functools import wraps from typing import Optional, Tuple -from bson.dbref import DBRef from bson.objectid import ObjectId from flask import current_app, jsonify, make_response, Response from pymongo import ReturnDocument @@ -49,8 +48,6 @@ try: users_collection.create_index("user_id", unique=True) except Exception as e: print("Error creating indexes:", e) - - current_dir = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ) diff --git a/application/api/user/conversations/routes.py b/application/api/user/conversations/routes.py index 5151babe..f3f965f3 100644 --- a/application/api/user/conversations/routes.py +++ b/application/api/user/conversations/routes.py @@ -7,11 +7,7 @@ from flask import current_app, jsonify, make_response, request from flask_restx import fields, Namespace, Resource from application.api import api -from application.api.user.base import ( - attachments_collection, - conversations_collection, - db, -) +from application.api.user.base import attachments_collection, conversations_collection from application.utils import check_required_fields conversations_ns = Namespace( diff --git a/application/api/user/sources/upload.py b/application/api/user/sources/upload.py index d4a44335..6c8c692d 100644 --- a/application/api/user/sources/upload.py +++ b/application/api/user/sources/upload.py @@ -1,7 +1,9 @@ """Source document management upload functionality.""" -import json, tempfile, zipfile +import json import os +import tempfile +import zipfile from bson.objectid import ObjectId from flask import current_app, jsonify, make_response, request