support chat v3
This commit is contained in:
SDE
2023-08-16 15:33:46 +03:00
parent 4d8ee4bfcc
commit e86aa76002
4 changed files with 25 additions and 10 deletions

View File

@@ -49,16 +49,18 @@ class ResponseInterceptionMiddleware:
# def process_view(self, request, view_func, *view_args, **view_kwargs):
#
# if request.user.is_authenticated and request.body:
# for_save_to_session = request.user.user_profile.pop_node_by_name('for_save_to_session')
# if for_save_to_session:
# data = json.loads(request.body)
# data.update(for_save_to_session)
# request.META.update({'ws_port': settings.WS_PORT})
#
# # request_data = getattr(request, '_body', request.body)
# # request_data = json.loads(request_data)
# # # here you can write the logic to append the payload to request data
# request._body = json.dumps(data)
# # if request.user.is_authenticated and request.body:
# # for_save_to_session = request.user.user_profile.pop_node_by_name('for_save_to_session')
# # if for_save_to_session:
# # data = json.loads(request.body)
# # data.update(for_save_to_session)
# #
# # # request_data = getattr(request, '_body', request.body)
# # # request_data = json.loads(request_data)
# # # # here you can write the logic to append the payload to request data
# # request._body = json.dumps(data)
# return None
# def __call__(self, request):

View File

@@ -1,5 +1,6 @@
from django import template
from django.template.defaultfilters import stringfilter
from django.conf import settings
register = template.Library()
@@ -10,6 +11,12 @@ register = template.Library()
# from django.utils.html import mark_safe
# @register.filter('get_msg_side')
@register.simple_tag
def get_ws_port():
return settings.WS_PORT
@register.simple_tag
def get_msg_side(cur_user, ticket, msg):
if msg:

View File

@@ -91,10 +91,14 @@ TEMPLATES = [
# WSGI_APPLICATION = 'TWB.wsgi.application'
ASGI_APPLICATION = 'TWB.asgi.application'
WS_PORT = 8000
CHANNEL_LAYERS = {
'default': {
# 'BACKEND': 'channels.layers.InMemoryChannelLayer',
"BACKEND": "channels_redis.core.RedisChannelLayer",
# 'USER': 'spadredis-zxs-service',
# 'PASSWORD': '9zghygpri84f8vl',
"CONFIG": {
"hosts": [("127.0.0.1", 6379)],
},

View File

@@ -1,4 +1,6 @@
{% load static %}
{% load tt_chat %}
<!DOCTYPE html>
<html lang="en">
<head>
@@ -10,7 +12,7 @@
<script>
{#var user_id = {{ user.id }}#}
ws_url = `ws://localhost:{{ ws_port }}/ws/socket-server/?user_id={{ user.id }}`;
ws_url = `ws://localhost:{% get_ws_port %}/ws/socket-server/?user_id={{ user.id }}`;
</script>