refactor: use composite unique index in Email Account (#28417)
This commit is contained in:
parent
0e3233d592
commit
c62e7334bc
3 changed files with 13 additions and 4 deletions
|
|
@ -95,8 +95,7 @@
|
|||
"in_list_view": 1,
|
||||
"label": "Email Address",
|
||||
"options": "Email",
|
||||
"reqd": 1,
|
||||
"unique": 1
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
|
|
@ -697,7 +696,7 @@
|
|||
"icon": "fa fa-inbox",
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-07-18 11:05:57.193762",
|
||||
"modified": "2024-11-11 10:12:06.667888",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Email",
|
||||
"name": "Email Account",
|
||||
|
|
|
|||
|
|
@ -1034,3 +1034,11 @@ def set_email_password(email_account, password):
|
|||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def on_doctype_update() -> None:
|
||||
frappe.db.add_unique(
|
||||
"Email Account",
|
||||
["email_id", "enable_incoming", "enable_outgoing"],
|
||||
constraint_name="unique_email_account_type",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -432,7 +432,9 @@ class Email:
|
|||
_from_email = self.decode_email(self.mail.get("X-Original-From") or self.mail["From"])
|
||||
_reply_to = self.decode_email(self.mail.get("Reply-To"))
|
||||
|
||||
if _reply_to and not frappe.db.get_value("Email Account", {"email_id": _reply_to}, "email_id"):
|
||||
if _reply_to and not frappe.db.get_value(
|
||||
"Email Account", {"email_id": _reply_to, "enable_incoming": 1}, "email_id"
|
||||
):
|
||||
self.from_email = extract_email_id(_reply_to)
|
||||
else:
|
||||
self.from_email = extract_email_id(_from_email)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue