Add SSL flexibility to chat server
This commit is contained in:
parent
349389ce93
commit
6d192cf54d
3 changed files with 12 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -13,4 +13,6 @@ resources/ranks.css
|
|||
resources/table.css
|
||||
sass_processed
|
||||
<desired bridge log path>
|
||||
node_modules/
|
||||
package-lock.json
|
||||
|
||||
|
|
|
@ -57,6 +57,14 @@ class ChatView(ListView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
# hard code, should be fixed later
|
||||
address = f'{self.request.get_host()}/ws/chat/'
|
||||
if self.request.is_secure():
|
||||
context['ws_address'] = f'wss://{address}'
|
||||
else:
|
||||
context['ws_address'] = f'ws://{address}'
|
||||
|
||||
context['title'] = self.title
|
||||
last_five_minutes = timezone.now()-timezone.timedelta(minutes=5)
|
||||
context['online_users'] = Profile.objects \
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
{% block js_media %}
|
||||
|
||||
<script type="text/javascript">
|
||||
var chatSocket = new WebSocket(
|
||||
'ws://' + window.location.host +
|
||||
'/ws/chat/');
|
||||
// change ws to wss if using HTTPS
|
||||
var chatSocket = new WebSocket( "{{ws_address}}" );
|
||||
</script>
|
||||
<script type="text/javascript" src="{{ static('mathjax_config.js') }}"></script>
|
||||
<script type="text/javascript"
|
||||
|
|
Loading…
Reference in a new issue