Merge pull request #34439 from frappe/fix/internal-communication
fix: consider sent or received for duplicate check
This commit is contained in:
commit
0b6ba2c709
3 changed files with 14 additions and 3 deletions
|
|
@ -416,6 +416,13 @@ class Communication(Document, CommunicationEmailMixin):
|
|||
|
||||
# Timeline Links
|
||||
def set_timeline_links(self):
|
||||
# Skip timeline links if a "Sent" communication already exists
|
||||
# else will create duplicate timeline entries
|
||||
if self.sent_or_received == "Received" and self.find_one_by_filters(
|
||||
message_id=self.message_id, sent_or_received="Sent"
|
||||
):
|
||||
return
|
||||
|
||||
contacts = []
|
||||
create_contact_enabled = self.email_account and frappe.db.get_value(
|
||||
"Email Account", self.email_account, "create_contact"
|
||||
|
|
|
|||
|
|
@ -523,7 +523,7 @@ class TestInboundMail(IntegrationTestCase):
|
|||
mail_content = self.get_test_mail(fname="incoming-1.raw")
|
||||
message_id = Email(mail_content).message_id
|
||||
# Create new communication record in DB
|
||||
communication = self.new_communication(message_id=message_id)
|
||||
communication = self.new_communication(message_id=message_id, sent_or_received="Received")
|
||||
|
||||
email_account = frappe.get_doc("Email Account", "_Test Email Account 1")
|
||||
inbound_mail = InboundMail(mail_content, email_account, 12345, 1)
|
||||
|
|
|
|||
|
|
@ -720,7 +720,9 @@ class InboundMail(Email):
|
|||
if not self.message_id:
|
||||
return
|
||||
|
||||
return Communication.find_one_by_filters(message_id=self.message_id, order_by="creation DESC")
|
||||
return Communication.find_one_by_filters(
|
||||
message_id=self.message_id, sent_or_received="Received", order_by="creation DESC"
|
||||
)
|
||||
|
||||
def is_sender_same_as_receiver(self):
|
||||
return self.from_email == self.email_account.email_id
|
||||
|
|
@ -766,7 +768,9 @@ class InboundMail(Email):
|
|||
if not self.is_reply():
|
||||
return ""
|
||||
|
||||
communication = Communication.find_one_by_filters(message_id=self.in_reply_to)
|
||||
communication = Communication.find_one_by_filters(
|
||||
message_id=self.in_reply_to, order_by="creation DESC"
|
||||
)
|
||||
if not communication:
|
||||
if self.parent_email_queue() and self.parent_email_queue().communication:
|
||||
communication = Communication.find(self.parent_email_queue().communication, ignore_error=True)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue