0.3.25
support chat v3
This commit is contained in:
@@ -49,16 +49,18 @@ class ResponseInterceptionMiddleware:
|
|||||||
|
|
||||||
# def process_view(self, request, view_func, *view_args, **view_kwargs):
|
# def process_view(self, request, view_func, *view_args, **view_kwargs):
|
||||||
#
|
#
|
||||||
# if request.user.is_authenticated and request.body:
|
# request.META.update({'ws_port': settings.WS_PORT})
|
||||||
# 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)
|
# # if request.user.is_authenticated and request.body:
|
||||||
# # request_data = json.loads(request_data)
|
# # for_save_to_session = request.user.user_profile.pop_node_by_name('for_save_to_session')
|
||||||
# # # here you can write the logic to append the payload to request data
|
# # if for_save_to_session:
|
||||||
# request._body = json.dumps(data)
|
# # 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
|
# return None
|
||||||
|
|
||||||
# def __call__(self, request):
|
# def __call__(self, request):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from django import template
|
from django import template
|
||||||
from django.template.defaultfilters import stringfilter
|
from django.template.defaultfilters import stringfilter
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@@ -10,6 +11,12 @@ register = template.Library()
|
|||||||
# from django.utils.html import mark_safe
|
# from django.utils.html import mark_safe
|
||||||
|
|
||||||
# @register.filter('get_msg_side')
|
# @register.filter('get_msg_side')
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def get_ws_port():
|
||||||
|
return settings.WS_PORT
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def get_msg_side(cur_user, ticket, msg):
|
def get_msg_side(cur_user, ticket, msg):
|
||||||
if msg:
|
if msg:
|
||||||
|
|||||||
@@ -91,10 +91,14 @@ TEMPLATES = [
|
|||||||
# WSGI_APPLICATION = 'TWB.wsgi.application'
|
# WSGI_APPLICATION = 'TWB.wsgi.application'
|
||||||
ASGI_APPLICATION = 'TWB.asgi.application'
|
ASGI_APPLICATION = 'TWB.asgi.application'
|
||||||
|
|
||||||
|
WS_PORT = 8000
|
||||||
|
|
||||||
CHANNEL_LAYERS = {
|
CHANNEL_LAYERS = {
|
||||||
'default': {
|
'default': {
|
||||||
# 'BACKEND': 'channels.layers.InMemoryChannelLayer',
|
# 'BACKEND': 'channels.layers.InMemoryChannelLayer',
|
||||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||||
|
# 'USER': 'spadredis-zxs-service',
|
||||||
|
# 'PASSWORD': '9zghygpri84f8vl',
|
||||||
"CONFIG": {
|
"CONFIG": {
|
||||||
"hosts": [("127.0.0.1", 6379)],
|
"hosts": [("127.0.0.1", 6379)],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load tt_chat %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@@ -10,7 +12,7 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
{#var user_id = {{ user.id }}#}
|
{#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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user