2024-04-22 22:22:18 +00:00
|
|
|
# Copyright (C) 2024 by Animath
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2024-04-27 06:57:01 +00:00
|
|
|
|
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
from django.views.generic import TemplateView
|
|
|
|
|
2024-04-27 10:08:10 +00:00
|
|
|
from chat.models import Channel
|
|
|
|
|
2024-04-27 06:57:01 +00:00
|
|
|
|
|
|
|
class ChatView(LoginRequiredMixin, TemplateView):
|
|
|
|
"""
|
|
|
|
This view is the main interface of the chat system, which is working
|
|
|
|
with Javascript and websockets.
|
|
|
|
"""
|
|
|
|
template_name = "chat/chat.html"
|
2024-04-27 10:08:10 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
from asgiref.sync import async_to_sync
|
|
|
|
context['channels'] = async_to_sync(Channel.get_accessible_channels)(self.request.user, 'read')
|
|
|
|
return context
|