Skip to content

Commit

Permalink
change sessions response
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshuamjv2 committed Oct 21, 2024
1 parent 32efa1c commit 5bab0a8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sessions/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ async def get_sessions(user=Depends(get_current_user)):
sessions = list(db["sessions"].find({"user": user["_id"]}))
for session in sessions:
session["id"] = session.pop("_id")
if len(session["block_lists"]) > 0:
block_lists = db["block_lists"].find({"_id": {"$in": session["block_lists"]}})
if block_lists:
block_lists = list(block_lists)
session["block_lists"] = block_lists
print(sessions)
return sessions

Expand All @@ -70,6 +75,11 @@ async def get_single_session(id: str, user=Depends(get_current_user)):
session = db["sessions"].find_one({"_id": id})
if session:
session["id"] = session.pop("_id")
if len(session["block_lists"]) > 0:
block_lists = db["session"].find({"_id": {"$in": session["block_lists"]}})
if block_lists:
block_lists = list(block_lists)
session["block_lists"] = block_lists
return session
raise HTTPException(status_code=400, detail="Session not found.")

Expand Down

0 comments on commit 5bab0a8

Please sign in to comment.