Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions astrbot/core/platform/sources/wecom/wecom_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Any, cast
from urllib.parse import unquote

from fastapi.responses import Response as FastAPIResponse
from requests import Response
from wechatpy.enterprise import WeChatClient, parse_message
from wechatpy.enterprise.crypto import WeChatCrypto
Expand Down Expand Up @@ -97,7 +98,7 @@ async def verify(self, request):
"""内部服务器的 GET 验证入口"""
return await self.handle_verify(request)

async def handle_verify(self, request) -> str:
async def handle_verify(self, request) -> FastAPIResponse:
"""处理验证请求,可被统一 webhook 入口复用

Args:
Expand All @@ -116,7 +117,7 @@ async def handle_verify(self, request) -> str:
args.get("echostr"),
)
logger.info("验证请求有效性成功。")
return echo_str
return FastAPIResponse(content=echo_str, media_type="text/plain")
Comment thread
sourcery-ai[bot] marked this conversation as resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

由于 handle_verify 方法现在返回的是 FastAPIResponse 对象,建议将该方法的返回类型标注(位于第 101 行:async def handle_verify(self, request) -> str:)更新为 FastAPIResponse,以保持类型声明的准确性,避免静态类型检查工具(如 mypy 或 pyright)报错。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

except InvalidSignatureException:
logger.error("验证请求有效性失败,签名异常,请检查配置。")
raise
Expand Down
3 changes: 3 additions & 0 deletions astrbot/dashboard/api/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any

from fastapi import APIRouter, Depends, Request
from fastapi.responses import Response

from astrbot.dashboard.asgi_runtime import DashboardRequest
from astrbot.dashboard.async_utils import run_maybe_async
Expand Down Expand Up @@ -50,6 +51,8 @@ def _model_dict(payload) -> dict[str, Any]:
async def _run(operation):
try:
result = await run_maybe_async(operation)
if isinstance(result, Response):
return result
return ok(result)
except PlatformServiceError as exc:
_raise_platform_error(exc)
Expand Down