mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
apply platform from envs in priority: non-dry
This commit is contained in:
@@ -190,13 +190,18 @@ async def rooms_list(
|
|||||||
|
|
||||||
user_id = user["sub"] if user else None
|
user_id = user["sub"] if user else None
|
||||||
|
|
||||||
return await apaginate(
|
paginated = await apaginate(
|
||||||
get_database(),
|
get_database(),
|
||||||
await rooms_controller.get_all(
|
await rooms_controller.get_all(
|
||||||
user_id=user_id, order_by="-created_at", return_query=True
|
user_id=user_id, order_by="-created_at", return_query=True
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for room in paginated.items:
|
||||||
|
room.platform = get_platform_for_room(room.id, room.platform)
|
||||||
|
|
||||||
|
return paginated
|
||||||
|
|
||||||
|
|
||||||
@router.get("/rooms/{room_id}", response_model=RoomDetails)
|
@router.get("/rooms/{room_id}", response_model=RoomDetails)
|
||||||
async def rooms_get(
|
async def rooms_get(
|
||||||
@@ -209,6 +214,7 @@ async def rooms_get(
|
|||||||
raise HTTPException(status_code=404, detail="Room not found")
|
raise HTTPException(status_code=404, detail="Room not found")
|
||||||
if not room.is_shared and (user_id is None or room.user_id != user_id):
|
if not room.is_shared and (user_id is None or room.user_id != user_id):
|
||||||
raise HTTPException(status_code=403, detail="Room access denied")
|
raise HTTPException(status_code=403, detail="Room access denied")
|
||||||
|
room.platform = get_platform_for_room(room.id, room.platform)
|
||||||
return room
|
return room
|
||||||
|
|
||||||
|
|
||||||
@@ -222,17 +228,16 @@ async def rooms_get_by_name(
|
|||||||
if not room:
|
if not room:
|
||||||
raise HTTPException(status_code=404, detail="Room not found")
|
raise HTTPException(status_code=404, detail="Room not found")
|
||||||
|
|
||||||
# Convert to RoomDetails format (add webhook fields if user is owner)
|
|
||||||
room_dict = room.__dict__.copy()
|
room_dict = room.__dict__.copy()
|
||||||
if user_id == room.user_id:
|
if user_id == room.user_id:
|
||||||
# User is owner, include webhook details if available
|
|
||||||
room_dict["webhook_url"] = getattr(room, "webhook_url", None)
|
room_dict["webhook_url"] = getattr(room, "webhook_url", None)
|
||||||
room_dict["webhook_secret"] = getattr(room, "webhook_secret", None)
|
room_dict["webhook_secret"] = getattr(room, "webhook_secret", None)
|
||||||
else:
|
else:
|
||||||
# Non-owner, hide webhook details
|
|
||||||
room_dict["webhook_url"] = None
|
room_dict["webhook_url"] = None
|
||||||
room_dict["webhook_secret"] = None
|
room_dict["webhook_secret"] = None
|
||||||
|
|
||||||
|
room_dict["platform"] = get_platform_for_room(room.id, room.platform)
|
||||||
|
|
||||||
return RoomDetails(**room_dict)
|
return RoomDetails(**room_dict)
|
||||||
|
|
||||||
|
|
||||||
@@ -277,6 +282,7 @@ async def rooms_update(
|
|||||||
raise HTTPException(status_code=403, detail="Not authorized")
|
raise HTTPException(status_code=403, detail="Not authorized")
|
||||||
values = info.dict(exclude_unset=True)
|
values = info.dict(exclude_unset=True)
|
||||||
await rooms_controller.update(room, values)
|
await rooms_controller.update(room, values)
|
||||||
|
room.platform = get_platform_for_room(room.id, room.platform)
|
||||||
return room
|
return room
|
||||||
|
|
||||||
|
|
||||||
@@ -352,6 +358,8 @@ async def rooms_create_meeting(
|
|||||||
status_code=503, detail="Meeting creation in progress, please try again"
|
status_code=503, detail="Meeting creation in progress, please try again"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
meeting.platform = get_platform_for_room(room.id, room.platform)
|
||||||
|
|
||||||
if meeting.platform == "daily" and room.recording_trigger != "none":
|
if meeting.platform == "daily" and room.recording_trigger != "none":
|
||||||
client = create_platform_client(meeting.platform)
|
client = create_platform_client(meeting.platform)
|
||||||
token = await client.create_meeting_token(
|
token = await client.create_meeting_token(
|
||||||
@@ -516,7 +524,10 @@ async def rooms_list_active_meetings(
|
|||||||
room=room, current_time=current_time
|
room=room, current_time=current_time
|
||||||
)
|
)
|
||||||
|
|
||||||
# Hide host URLs from non-owners
|
effective_platform = get_platform_for_room(room.id, room.platform)
|
||||||
|
for meeting in meetings:
|
||||||
|
meeting.platform = effective_platform
|
||||||
|
|
||||||
if user_id != room.user_id:
|
if user_id != room.user_id:
|
||||||
for meeting in meetings:
|
for meeting in meetings:
|
||||||
meeting.host_room_url = ""
|
meeting.host_room_url = ""
|
||||||
@@ -546,6 +557,8 @@ async def rooms_get_meeting(
|
|||||||
status_code=403, detail="Meeting does not belong to this room"
|
status_code=403, detail="Meeting does not belong to this room"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
meeting.platform = get_platform_for_room(room.id, room.platform)
|
||||||
|
|
||||||
if user_id != room.user_id and not room.is_shared:
|
if user_id != room.user_id and not room.is_shared:
|
||||||
meeting.host_room_url = ""
|
meeting.host_room_url = ""
|
||||||
|
|
||||||
@@ -581,7 +594,8 @@ async def rooms_join_meeting(
|
|||||||
if meeting.end_date <= current_time:
|
if meeting.end_date <= current_time:
|
||||||
raise HTTPException(status_code=400, detail="Meeting has ended")
|
raise HTTPException(status_code=400, detail="Meeting has ended")
|
||||||
|
|
||||||
# Hide host URL from non-owners
|
meeting.platform = get_platform_for_room(room.id, room.platform)
|
||||||
|
|
||||||
if user_id != room.user_id:
|
if user_id != room.user_id:
|
||||||
meeting.host_room_url = ""
|
meeting.host_room_url = ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user