feat(trigger): add trigger provider management and webhook handling functionality

This commit is contained in:
Harry
2025-08-28 11:46:35 +08:00
parent 7544b5ec9a
commit 87120ad4ac
28 changed files with 2056 additions and 57 deletions

View File

@ -4,4 +4,4 @@ from flask import Blueprint
bp = Blueprint("trigger", __name__, url_prefix="/triggers")
# Import routes after blueprint creation to avoid circular imports
from . import webhook
from . import trigger, webhook

View File

@ -0,0 +1,23 @@
import logging
from flask import jsonify, request
from werkzeug.exceptions import NotFound
from controllers.trigger import bp
from services.trigger_service import TriggerService
logger = logging.getLogger(__name__)
@bp.route("/trigger/webhook/<string:endpoint_id>", methods=["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"])
def trigger_webhook(endpoint_id: str):
"""
Handle webhook trigger calls.
"""
try:
return TriggerService.process_webhook(endpoint_id, request)
except ValueError as e:
raise NotFound(str(e))
except Exception as e:
logger.exception("Webhook processing failed for {endpoint_id}")
return jsonify({"error": "Internal server error", "message": str(e)}), 500