@@ -145,6 +145,11 @@ def __init__(
145145 view_func = self .srv_plug_route ,
146146 methods = ["GET" , "POST" ],
147147 )
148+ self .app .add_url_rule (
149+ "/api/plug/webhook/<webhook_uuid>" ,
150+ view_func = self .srv_plug_webhook_route ,
151+ methods = ["GET" , "POST" ],
152+ )
148153
149154 self .shutdown_event = shutdown_event
150155
@@ -159,6 +164,21 @@ async def srv_plug_route(self, subpath, *args, **kwargs):
159164 return await view_handler (* args , ** kwargs )
160165 return jsonify (Response ().error ("未找到该路由" ).__dict__ )
161166
167+ async def srv_plug_webhook_route (self , webhook_uuid , * args , ** kwargs ):
168+ """插件统一 Webhook 路由"""
169+ registered_unified_webhooks = (
170+ self .core_lifecycle .star_context .registered_unified_webhooks
171+ )
172+ callback = registered_unified_webhooks .get (webhook_uuid )
173+ if not callback :
174+ return jsonify (Response ().error ("未找到对应 webhook" ).__dict__ ), 404
175+
176+ view_handler , methods , _ = callback
177+ if request .method not in methods :
178+ return jsonify (Response ().error ("请求方法不被允许" ).__dict__ ), 405
179+
180+ return await view_handler (* args , ** kwargs )
181+
162182 async def auth_middleware (self ):
163183 if not request .path .startswith ("/api" ):
164184 return None
@@ -199,6 +219,7 @@ async def auth_middleware(self):
199219 allowed_endpoints = [
200220 "/api/auth/login" ,
201221 "/api/file" ,
222+ "/api/plug/webhook" ,
202223 "/api/platform/webhook" ,
203224 "/api/stat/start-time" ,
204225 "/api/backup/download" , # 备份下载使用 URL 参数传递 token
0 commit comments