修复密码房问题
This commit is contained in:
@@ -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)
|
return await _end_room_if_empty(db, room_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ===== API ENDPOINTS =====
|
# ===== API ENDPOINTS =====
|
||||||
|
|
||||||
@router.post("/multiplayer/rooms")
|
@router.post("/multiplayer/rooms")
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ async def get_all_rooms(
|
|||||||
|
|
||||||
if status is not None:
|
if status is not None:
|
||||||
where_clauses.append(col(Room.status) == status)
|
where_clauses.append(col(Room.status) == status)
|
||||||
print(mode, category, status, current_user.id)
|
#print(mode, category, status, current_user.id)
|
||||||
if mode == "open":
|
if mode == "open":
|
||||||
# 修改为新的查询逻辑:状态为 idle 或 playing,starts_at 不为空,ends_at 为空
|
# 修改为新的查询逻辑:状态为 idle 或 playing,starts_at 不为空,ends_at 为空
|
||||||
where_clauses.extend([
|
where_clauses.extend([
|
||||||
@@ -96,13 +96,13 @@ async def get_all_rooms(
|
|||||||
.unique()
|
.unique()
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
print("Retrieved rooms:", db_rooms)
|
#print("Retrieved rooms:", db_rooms)
|
||||||
for room in db_rooms:
|
for room in db_rooms:
|
||||||
resp = await RoomResp.from_db(room, db)
|
resp = await RoomResp.from_db(room, db)
|
||||||
|
resp.has_password = bool((room.password or "").strip())
|
||||||
if category == RoomCategory.REALTIME:
|
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.category = RoomCategory.NORMAL
|
||||||
|
|
||||||
resp_list.append(resp)
|
resp_list.append(resp)
|
||||||
|
|
||||||
return resp_list
|
return resp_list
|
||||||
|
|||||||
Reference in New Issue
Block a user