refactor: 优化异步调用和权限系统架构

- 移除bot.py中不必要的asyncio.to_thread包装
- 将权限API的is_master方法改为异步调用
- 删除不再使用的SQLAlchemyTransaction类
This commit is contained in:
雅诺狐
2025-10-06 21:02:38 +08:00
committed by Windpicker-owo
parent 50c8555f00
commit 694f1f8c69
4 changed files with 5 additions and 34 deletions

View File

@@ -36,7 +36,7 @@ class IPermissionManager(ABC):
async def check_permission(self, user: UserInfo, permission_node: str) -> bool: ...
@abstractmethod
def is_master(self, user: UserInfo) -> bool: ... # 同步快速判断
async def is_master(self, user: UserInfo) -> bool: ... # 同步快速判断
@abstractmethod
async def register_permission_node(self, node: PermissionNode) -> bool: ...
@@ -82,9 +82,9 @@ class PermissionAPI:
self._ensure_manager()
return await self._permission_manager.check_permission(UserInfo(platform, user_id), permission_node)
def is_master(self, platform: str, user_id: str) -> bool:
async def is_master(self, platform: str, user_id: str) -> bool:
self._ensure_manager()
return self._permission_manager.is_master(UserInfo(platform, user_id))
return await self._permission_manager.is_master(UserInfo(platform, user_id))
async def register_permission_node(
self,