emile 8 months ago
parent 693b1a858e
commit 938ecbd32c

Binary file not shown.

@ -571,6 +571,11 @@ class OsitcomChatRoom(WebsocketConsumer):
if self.client_type == 'mobile_admin': if self.client_type == 'mobile_admin':
chat_room_data = model_to_dict(chat_room) chat_room_data = model_to_dict(chat_room)
chat_room_data['visitor'] = {
'id': chat_room.chatroomguest.visitor.id,
'country_flag': chat_room.chatroomguest.visitor.flag_image_url,
'is_online': chat_room.chatroomguest.visitor.is_online,
}
chat_room_messages_data = [] chat_room_messages_data = []
for message in chat_room_messages: for message in chat_room_messages:
@ -657,7 +662,6 @@ class OsitcomChatRoom(WebsocketConsumer):
'domain': self.domain 'domain': self.domain
} }
if self.client_type == 'mobile_admin': if self.client_type == 'mobile_admin':
member_data = None
if member: if member:
member_data = model_to_dict(member) member_data = model_to_dict(member)
member_data['image'] = member.staffprofile.image.url if member.staffprofile and member.staffprofile.image else None member_data['image'] = member.staffprofile.image.url if member.staffprofile and member.staffprofile.image else None

@ -0,0 +1,18 @@
# Generated by Django 4.2.5 on 2024-09-06 06:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('osichat', '0028_chatnotification_type_id'),
]
operations = [
migrations.AddField(
model_name='chatnotification',
name='session_id',
field=models.CharField(max_length=200, null=True),
),
]

@ -53,7 +53,7 @@ def send_notification(notification):
body=notification_data['body'], body=notification_data['body'],
image=notification.image if notification.image else None, image=notification.image if notification.image else None,
), ),
data={"id": str(notification.type_id), "type": notification.type}, data={"id": str(notification.type_id), "type": notification.type, "session_id": notification.session_id},
android=android_config, android=android_config,
apns=apns_config apns=apns_config
) )
@ -110,6 +110,7 @@ class ChatNotification(models.Model):
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
type = models.CharField(max_length=8, choices=TYPES, null=True) type = models.CharField(max_length=8, choices=TYPES, null=True)
type_id = models.IntegerField(null=True) type_id = models.IntegerField(null=True)
session_id = models.CharField(max_length=200, null=True)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
is_new = not self.pk is_new = not self.pk
super().save(*args, **kwargs) super().save(*args, **kwargs)
@ -218,6 +219,7 @@ class VisitorLog(models.Model):
def send_visitor_notification(self, is_repeat=False): def send_visitor_notification(self, is_repeat=False):
type_id = self.visitor.id type_id = self.visitor.id
session_id = self.visitor.session_id
if is_repeat: if is_repeat:
title = "Existing visitor new acitivity on Ositcom!" title = "Existing visitor new acitivity on Ositcom!"
if self.title: if self.title:
@ -235,7 +237,9 @@ class VisitorLog(models.Model):
message = body, message = body,
image = self.visitor.notification_flag_image_url, image = self.visitor.notification_flag_image_url,
type = "Visitor", type = "Visitor",
type_id = type_id type_id = type_id,
session_id=session_id
) )
@ -282,6 +286,7 @@ class ChatRoomGuest(models.Model):
self.send_chat_notification() self.send_chat_notification()
def send_chat_notification(self): def send_chat_notification(self):
type_id = self.id type_id = self.id
session_id = self.visitor.session_id
title = "New chat on Ositcom!" title = "New chat on Ositcom!"
body = f"Visitor {self.visitor.ip_address} started a new chat on Ositcom" body = f"Visitor {self.visitor.ip_address} started a new chat on Ositcom"
notification = ChatNotification.objects.create( notification = ChatNotification.objects.create(
@ -289,7 +294,8 @@ class ChatRoomGuest(models.Model):
message = body, message = body,
image = self.visitor.notification_flag_image_url, image = self.visitor.notification_flag_image_url,
type = "Chat", type = "Chat",
type_id = type_id type_id = type_id,
session_id = session_id
) )
class ChatRoomReview(models.Model): class ChatRoomReview(models.Model):
@ -331,6 +337,7 @@ class ChatMessage(models.Model):
self.send_message_notification() self.send_message_notification()
def send_message_notification(self): def send_message_notification(self):
type_id = self.id type_id = self.id
session_id = self.room.chatroomguest.visitor.session_id
title = f"Visitor {self.room.chatroomguest.visitor.ip_address} sent a new message on Ositcom!" title = f"Visitor {self.room.chatroomguest.visitor.ip_address} sent a new message on Ositcom!"
body = f"{self.content}" body = f"{self.content}"
notification = ChatNotification.objects.create( notification = ChatNotification.objects.create(
@ -338,7 +345,8 @@ class ChatMessage(models.Model):
message = body, message = body,
image = self.room.chatroomguest.visitor.notification_flag_image_url, image = self.room.chatroomguest.visitor.notification_flag_image_url,
type = "Chat", type = "Chat",
type_id = type_id type_id = type_id,
session_id = session_id
) )

Loading…
Cancel
Save