修复密码房问题

This commit is contained in:
咕谷酱
2025-08-24 06:17:05 +08:00
committed by MingxuanGame
parent 35a7bc19da
commit 6fa9d5ba79
2 changed files with 4 additions and 6 deletions

View File

@@ -490,8 +490,6 @@ async def _transfer_ownership_or_end_room(db: Database, room_id: int, leaving_us
# 没有其他参与者,结束房间
return await _end_room_if_empty(db, room_id)
# ===== API ENDPOINTS =====
@router.post("/multiplayer/rooms")

View File

@@ -59,7 +59,7 @@ async def get_all_rooms(
if status is not None:
where_clauses.append(col(Room.status) == status)
print(mode, category, status, current_user.id)
#print(mode, category, status, current_user.id)
if mode == "open":
# 修改为新的查询逻辑:状态为 idle 或 playingstarts_at 不为空ends_at 为空
where_clauses.extend([
@@ -96,13 +96,13 @@ async def get_all_rooms(
.unique()
.all()
)
print("Retrieved rooms:", db_rooms)
#print("Retrieved rooms:", db_rooms)
for room in db_rooms:
resp = await RoomResp.from_db(room, db)
resp.has_password = bool((room.password or "").strip())
if category == RoomCategory.REALTIME:
mp_room = MultiplayerHubs.rooms.get(room.id)
resp.has_password = bool(mp_room.room.settings.password.strip()) if mp_room is not None else False
resp.category = RoomCategory.NORMAL
resp_list.append(resp)
return resp_list