Browse Source

Implement critical fix for session handling and add centralized metadata structure

- Updated CourseLiveSessionRoomCreateAPIView to filter out ended sessions by adding `ended_at__isnull=True` in the session creation logic.
- Introduced a new method in CourseLiveSessionTokenAPIView to build centralized metadata for room settings, ensuring client overrides are not permitted and defining default lock settings and room features.
shokhmgar
mortezaei 10 months ago
parent
commit
f62387d108
  1. 56
      apps/course/views/live_session.py

56
apps/course/views/live_session.py

@ -97,8 +97,9 @@ class CourseLiveSessionRoomCreateAPIView(GenericAPIView):
raise AppAPIException({'message': str(exc)}, status_code=500) raise AppAPIException({'message': str(exc)}, status_code=500)
# 5. Database Logic # 5. Database Logic
# CRITICAL FIX: Also filter by ended_at__isnull=True to avoid reusing ended sessions
session, created = CourseLiveSession.objects.get_or_create( session, created = CourseLiveSession.objects.get_or_create(
course=course, room_id=room_id,
course=course, room_id=room_id, ended_at__isnull=True,
defaults={'subject': subject, 'started_at': timezone.now()} defaults={'subject': subject, 'started_at': timezone.now()}
) )
@ -396,6 +397,59 @@ class CourseLiveSessionTokenAPIView(GenericAPIView):
'plugnmeet': plugnmeet_response, 'plugnmeet': plugnmeet_response,
}) })
def _build_metadata(self, subject: str) -> dict:
# Build secured, centralized metadata. Client overrides are NOT allowed.
return {
'room_title': subject,
'default_lock_settings': {
'lock_microphone': True,
'lock_webcam': True,
'lock_screen_sharing': True,
'lock_whiteboard': False,
'lock_shared_notepad': False,
'lock_chat': False,
'lock_chat_send_message': False,
'lock_chat_file_share': False,
'lock_private_chat': False,
},
'room_features': {
'allow_webcams': True,
'mute_on_start': True,
'allow_screen_sharing': True,
'allow_recording': True,
'allow_rtmp': False,
'allow_view_other_webcams': True,
'allow_view_other_participants_list': True,
'admin_only_webcams': False,
'allow_polls': True,
'room_duration': 0,
'chat_features': {
'allow_chat': True,
'allow_file_upload': True,
},
'shared_note_pad_features': {
'allowed_shared_note_pad': True,
},
'whiteboard_features': {
'allowed_whiteboard': True,
},
'breakout_room_features': {
'is_allow': True,
'allowed_number_rooms': 6,
},
'waiting_room_features': {
'is_active': False,
},
'recording_features': {
'is_allow': True,
'is_allow_cloud': True,
'is_allow_local': True,
'enable_auto_cloud_recording': False,
'only_record_admin_webcams': False,
},
},
}
@staticmethod @staticmethod
def _verify_room_is_active(session: CourseLiveSession) -> bool: def _verify_room_is_active(session: CourseLiveSession) -> bool:
""" """

Loading…
Cancel
Save