mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-06 20:16:47 +00:00
🐛 fix cqhttp secret checking #289
This commit is contained in:
@ -16,7 +16,7 @@ from typing import List, Optional, Callable
|
||||
import uvicorn
|
||||
from pydantic import BaseSettings
|
||||
from fastapi.responses import Response
|
||||
from fastapi import Body, status, Request, FastAPI, HTTPException
|
||||
from fastapi import status, Request, FastAPI, HTTPException
|
||||
from starlette.websockets import WebSocketDisconnect, WebSocket as FastAPIWebSocket
|
||||
|
||||
from nonebot.log import logger
|
||||
@ -177,11 +177,11 @@ class Driver(BaseDriver):
|
||||
**kwargs)
|
||||
|
||||
@overrides(BaseDriver)
|
||||
async def _handle_http(self,
|
||||
adapter: str,
|
||||
request: Request,
|
||||
data: dict = Body(...)):
|
||||
if not isinstance(data, dict):
|
||||
async def _handle_http(self, adapter: str, request: Request):
|
||||
data = await request.body()
|
||||
data_dict = json.loads(data.decode())
|
||||
|
||||
if not isinstance(data_dict, dict):
|
||||
logger.warning("Data received is invalid")
|
||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
@ -208,7 +208,7 @@ class Driver(BaseDriver):
|
||||
|
||||
bot = BotClass("http", x_self_id)
|
||||
|
||||
asyncio.create_task(bot.handle_message(data))
|
||||
asyncio.create_task(bot.handle_message(data_dict))
|
||||
return Response("", 204)
|
||||
|
||||
@overrides(BaseDriver)
|
||||
|
Reference in New Issue
Block a user