修复部分报错

This commit is contained in:
咕谷酱
2025-09-24 03:04:09 +08:00
parent 86c7bbb74e
commit 3a434ee02c
5 changed files with 113 additions and 13 deletions

View File

@@ -48,9 +48,18 @@ class ChatServer:
user_id = user.id
if user_id in self.connect_client:
del self.connect_client[user_id]
# 创建频道ID列表的副本以避免在迭代过程中修改字典
channel_ids_to_process = []
for channel_id, channel in self.channels.items():
if user_id in channel:
channel.remove(user_id)
channel_ids_to_process.append(channel_id)
# 现在安全地处理每个频道
for channel_id in channel_ids_to_process:
# 再次检查用户是否仍在频道中(防止并发修改)
if channel_id in self.channels and user_id in self.channels[channel_id]:
self.channels[channel_id].remove(user_id)
# 使用明确的查询避免延迟加载
db_channel = (
await session.exec(select(ChatChannel).where(ChatChannel.channel_id == channel_id))

View File

@@ -86,7 +86,7 @@ async def verify_session(
if verify_method is None:
# 智能选择验证方法参考osu-web实现
# API版本较老或用户未设置TOTP时强制使用邮件验证
print(api_version, totp_key)
#print(api_version, totp_key)
if api_version < 20240101 or totp_key is None:
verify_method = "mail"
else:
@@ -148,8 +148,8 @@ async def verify_session(
# 构建更详细的错误响应参考osu-web的错误处理
error_response = {
"method": verify_method,
"error": str(e),
"method": verify_method,
}
# 如果有具体的错误原因,添加到响应中