Skip to content

Commit

Permalink
fix: Allow emailing disabled user (#19382) (#19383)
Browse files Browse the repository at this point in the history
Not sure why we need to validate this. A disabled user can still exist
outside of system with same active email address.

(cherry picked from commit a18e63e)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed Dec 21, 2022
1 parent 0ab6a30 commit fb7f645
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions frappe/core/doctype/communication/mixins.py
Expand Up @@ -59,10 +59,7 @@ def mail_cc(self, is_inbound_mail_communcation=False, include_sender=False):
* if email copy is requested by sender, then add sender to CC.
* If this doc is created through inbound mail, then add doc owner to cc list
* remove all the thread_notify disabled users.
* Make sure that all users enabled in the system
* Remove admin from email list
* FixMe: Removed adding TODO owners to cc list. Check if that is needed.
* Remove standard users from email list
"""
if hasattr(self, "_final_cc"):
return self._final_cc
Expand All @@ -80,13 +77,12 @@ def mail_cc(self, is_inbound_mail_communcation=False, include_sender=False):

cc = set(cc) - set(self.filter_thread_notification_disbled_users(cc))
cc = cc - set(self.mail_recipients(is_inbound_mail_communcation=is_inbound_mail_communcation))
cc = cc - set(self.filter_disabled_users(cc))

# # Incase of inbound mail, to and cc already received the mail, no need to send again.
if is_inbound_mail_communcation:
cc = cc - set(self.cc_list() + self.to_list())

self._final_cc = list(filter(lambda id: id != "Administrator", cc))
self._final_cc = [m for m in cc if m not in frappe.STANDARD_USERS]
return self._final_cc

def get_mail_cc_with_displayname(self, is_inbound_mail_communcation=False, include_sender=False):
Expand All @@ -99,8 +95,7 @@ def mail_bcc(self, is_inbound_mail_communcation=False):
"""
* Thread_notify check
* Email unsubscribe list
* User must be enabled in the system
* remove_administrator_from_email_list
* remove standard users.
"""
if hasattr(self, "_final_bcc"):
return self._final_bcc
Expand All @@ -110,13 +105,12 @@ def mail_bcc(self, is_inbound_mail_communcation=False):
bcc = bcc - {self.sender_mailid}
bcc = bcc - set(self.filter_thread_notification_disbled_users(bcc))
bcc = bcc - set(self.mail_recipients(is_inbound_mail_communcation=is_inbound_mail_communcation))
bcc = bcc - set(self.filter_disabled_users(bcc))

# Incase of inbound mail, to and cc & bcc already received the mail, no need to send again.
if is_inbound_mail_communcation:
bcc = bcc - set(self.bcc_list() + self.to_list())

self._final_bcc = list(filter(lambda id: id != "Administrator", bcc))
self._final_bcc = [m for m in bcc if m not in frappe.STANDARD_USERS]
return self._final_bcc

def get_mail_bcc_with_displayname(self, is_inbound_mail_communcation=False):
Expand Down
2 changes: 1 addition & 1 deletion frappe/core/doctype/communication/test_communication.py
Expand Up @@ -343,7 +343,7 @@ def test_bcc(self):
user = self.new_user(email="bcc+2@test.com", enabled=0)
comm = self.new_communication(bcc=bcc_list)
res = comm.get_mail_bcc_with_displayname()
self.assertCountEqual(res, ["bcc+1@test.com"])
self.assertCountEqual(res, bcc_list)
user.delete()
comm.delete()

Expand Down

0 comments on commit fb7f645

Please sign in to comment.