Ejemplo n.º 1
0
	def after_insert(self):
		if not (self.reference_doctype and self.reference_name):
			return

		if self.reference_doctype == "Communication" and self.sent_or_received == "Sent":
			frappe.db.set_value("Communication", self.reference_name, "status", "Replied")

		if self.communication_type in ("Communication", "Comment"):
			# send new comment to listening clients
			frappe.publish_realtime('new_communication', self.as_dict(),
			    doctype=self.reference_doctype, docname=self.reference_name,
			    after_commit=True)

			if self.communication_type == "Comment":
				notify_mentions(self)

		elif self.communication_type in ("Chat", "Notification", "Bot"):
			if self.reference_name == frappe.session.user:
				message = self.as_dict()
				message['broadcast'] = True
				frappe.publish_realtime('new_message', message, after_commit=True)
			else:
				# reference_name contains the user who is addressed in the messages' page comment
				frappe.publish_realtime('new_message', self.as_dict(),
				    user=self.reference_name, after_commit=True)
Ejemplo n.º 2
0
    def after_insert(self):
        if not (self.reference_doctype and self.reference_name):
            return

        if self.communication_type in ("Communication", "Comment"):
            # send new comment to listening clients
            frappe.publish_realtime('new_communication',
                                    self.as_dict(),
                                    doctype=self.reference_doctype,
                                    docname=self.reference_name,
                                    after_commit=True)

            if self.communication_type == "Comment":
                notify_mentions(self)

        elif self.communication_type in ("Chat", "Notification", "Bot"):
            if self.reference_name == frappe.session.user:
                message = self.as_dict()
                message['broadcast'] = True
                frappe.publish_realtime('new_message',
                                        message,
                                        after_commit=True)
            else:
                # reference_name contains the user who is addressed in the messages' page comment
                frappe.publish_realtime('new_message',
                                        self.as_dict(),
                                        user=self.reference_name,
                                        after_commit=True)
Ejemplo n.º 3
0
    def after_insert(self):
        if not (self.reference_doctype and self.reference_name):
            return
        if not self.timeline_hide:
            if self.communication_type in ("Communication", "Comment"):
                # send new comment to listening clients
                frappe.publish_realtime(
                    "new_communication",
                    self.as_dict(),
                    doctype=self.reference_doctype,
                    docname=self.reference_name,
                    after_commit=True,
                )

                if self.communication_type == "Comment":
                    notify_mentions(self)

            elif self.communication_type in ("Chat", "Notification"):
                if self.reference_name == frappe.session.user:
                    message = self.as_dict()
                    message["broadcast"] = True
                    frappe.publish_realtime("new_message", message, after_commit=True)
                else:
                    # reference_name contains the user who is addressed in the messages' page comment
                    frappe.publish_realtime("new_message", self.as_dict(), user=self.reference_name, after_commit=True)