Skip to content

Commit

Permalink
fix: validate duplicate mail domain
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Nov 15, 2024
1 parent ffad64c commit b8299cd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mail_client/mail_client/doctype/mail_domain/mail_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def validate(self) -> None:
self.validate_newsletter_retention()

if self.is_new():
self.validate_duplicate()
self.access_token = generate_access_token()
self.dkim_private_key, self.dkim_public_key = generate_dkim_keys()
self.add_or_update_domain_in_mail_server()
Expand Down Expand Up @@ -50,6 +51,12 @@ def validate_newsletter_retention(self) -> None:
"Mail Client Settings", "default_newsletter_retention", cache=True
)

def validate_duplicate(self) -> None:
"""Validate if the Mail Domain already exists."""

if frappe.db.exists("Mail Domain", {"domain_name": self.domain_name}):
frappe.throw(_("Mail Domain {0} already exists.").format(frappe.bold(self.domain_name)))

def add_or_update_domain_in_mail_server(self) -> None:
"""Adds or Updates the Domain in the Mail Server."""

Expand Down

0 comments on commit b8299cd

Please sign in to comment.