fix webhooks

This commit is contained in:
jxxghp
2023-06-11 20:11:19 +08:00
parent f1a798cd05
commit 738335d16c
7 changed files with 36 additions and 22 deletions

View File

@ -1,3 +1,4 @@
from typing import Any
from fastapi import APIRouter, BackgroundTasks, Request
@ -8,11 +9,11 @@ from app.core.config import settings
router = APIRouter()
def start_webhook_chain(message: dict):
def start_webhook_chain(body: Any, form: Any, args: Any):
"""
启动链式任务
"""
WebhookMessageChain().process(message)
WebhookMessageChain().process(body=body, form=form, args=args)
@router.post("/", response_model=schemas.Response)
@ -22,6 +23,8 @@ async def webhook_message(background_tasks: BackgroundTasks, token: str, request
"""
if token != settings.API_TOKEN:
return {"success": False, "message": "token认证不通过"}
background_tasks.add_task(start_webhook_chain, await request.json())
body = await request.body()
form = await request.form()
args = request.query_params
background_tasks.add_task(start_webhook_chain, body, form, args)
return {"success": True}