From d1a21020ebac1b601c9a3cfa63d41d6b4bec2571 Mon Sep 17 00:00:00 2001 From: Zambom Date: Wed, 6 Sep 2017 00:22:19 -0300 Subject: [PATCH] Changing chat push notification function --- api/utils.py | 4 ++-- api/views.py | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/api/utils.py b/api/utils.py index 097424c..0c79904 100644 --- a/api/utils.py +++ b/api/utils.py @@ -32,11 +32,11 @@ def sendChatPushNotification(user, message): response = json.dumps(info) - title = str(user).join(_(" sent a message")) + title = str(message.user).join(_(" sent a message")) simple_notify = textwrap.shorten(strip_tags(message.text), width = 30, placeholder = "...") if message.image: simple_notify += " ".join(_("[Photo]")) - device.send_message(title = title, body = simple_notify, data = {"response": response}) \ No newline at end of file + device.send_message(data = {"response": response, "title": title, "body": simple_notify, "user_from": message.user.email, "user_name": str(message.user), "user_img": message.user.image_url}) \ No newline at end of file diff --git a/api/views.py b/api/views.py index 2ee8c70..ff52515 100644 --- a/api/views.py +++ b/api/views.py @@ -305,7 +305,14 @@ class ChatViewset(viewsets.ModelViewSet): talk.save() - subject = Subject.objects.get(slug = subject) + if subject != "": + subject = Subject.objects.get(slug = subject) + space = subject.slug + space_type = "subject" + else: + subject = None + space = 0 + space_type = "general" message = TalkMessages() message.text = "

" + msg_text + "

" @@ -320,11 +327,11 @@ class ChatViewset(viewsets.ModelViewSet): if not message.pk is None: simple_notify = textwrap.shorten(strip_tags(message.text), width = 30, placeholder = "...") - + notification = { "type": "chat", - "subtype": "subject", - "space": subject.slug, + "subtype": space_type, + "space": space, "user_icon": message.user.image_url, "notify_title": str(message.user), "simple_notify": simple_notify, -- libgit2 0.21.2