mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-22 08:15:13 +00:00
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Views for the Janus app.
|
|
"""
|
|
|
|
import copy
|
|
|
|
from django.views.generic import TemplateView
|
|
|
|
from freedombox import app as app_module
|
|
from freedombox.middleware import CONTENT_SECURITY_POLICY
|
|
|
|
|
|
class JanusRoomView(TemplateView):
|
|
"""A simple page to host Janus video room."""
|
|
template_name = 'janus_video_room.html'
|
|
headers: dict[str, str] = {}
|
|
|
|
def __init__(self, **kwargs):
|
|
"""Initialize the view and set CSP."""
|
|
super().__init__(**kwargs)
|
|
csp = copy.copy(CONTENT_SECURITY_POLICY)
|
|
csp['script-src'] = "'self' 'unsafe-inline'"
|
|
csp['style-src'] = "'self' 'unsafe-inline'"
|
|
self.headers['Content-Security-Policy'] = csp.get_header_value()
|
|
|
|
def get_context_data(self, *args, **kwargs):
|
|
"""Add user's TURN server information to view context."""
|
|
app = app_module.App.get('janus')
|
|
config = app.get_component('turn-janus').get_configuration()
|
|
context = super().get_context_data(*args, **kwargs)
|
|
context['user_turn_config'] = config.to_json()
|
|
return context
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
"""Handle GET request and return a response object."""
|
|
context = self.get_context_data(**kwargs)
|
|
return self.render_to_response(context, headers=self.headers)
|