♻️(backend) extract LiveKit connection info generation function

Extract serialization logic for LiveKit server connection data to make it
reusable across endpoints. Function naming will be improved in future
refactoring when utility functions are moved to a proper service.
This commit is contained in:
lebaudantoine
2025-02-18 17:44:14 +01:00
committed by aleb_the_flash
parent 01f4d05d6b
commit 710d7964ee
2 changed files with 22 additions and 10 deletions

View File

@@ -81,3 +81,21 @@ def generate_token(room: str, user, username: Optional[str] = None) -> str:
)
return token.to_jwt()
def generate_livekit_config(room_id: str, user, username: str) -> dict:
"""Generate LiveKit configuration for room access.
Args:
room_id: Room identifier
user: User instance requesting access
username: Display name in room
Returns:
dict: LiveKit configuration with URL, room and access token
"""
return {
"url": settings.LIVEKIT_CONFIGURATION["url"],
"room": room_id,
"token": generate_token(room=room_id, user=user, username=username),
}