|
|
@ -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
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|