-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
299 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors | ||
// For license information, please see license.txt | ||
|
||
// frappe.ui.form.on("Mail Group", { | ||
// refresh(frm) { | ||
|
||
// }, | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"actions": [], | ||
"creation": "2025-01-06 14:23:03.332903", | ||
"doctype": "DocType", | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"section_break_uwhi", | ||
"enabled", | ||
"column_break_zfbl", | ||
"domain_name", | ||
"email", | ||
"display_name" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "section_break_uwhi", | ||
"fieldtype": "Section Break" | ||
}, | ||
{ | ||
"default": "1", | ||
"depends_on": "eval: !doc.__islocal", | ||
"fieldname": "enabled", | ||
"fieldtype": "Check", | ||
"in_list_view": 1, | ||
"label": "Enabled", | ||
"search_index": 1 | ||
}, | ||
{ | ||
"fieldname": "domain_name", | ||
"fieldtype": "Link", | ||
"in_list_view": 1, | ||
"in_standard_filter": 1, | ||
"label": "Domain Name", | ||
"no_copy": 1, | ||
"options": "Mail Domain", | ||
"reqd": 1, | ||
"search_index": 1, | ||
"set_only_once": 1 | ||
}, | ||
{ | ||
"fieldname": "email", | ||
"fieldtype": "Data", | ||
"in_list_view": 1, | ||
"in_standard_filter": 1, | ||
"label": "Email", | ||
"no_copy": 1, | ||
"options": "Email", | ||
"reqd": 1, | ||
"set_only_once": 1, | ||
"unique": 1 | ||
}, | ||
{ | ||
"fieldname": "column_break_zfbl", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fieldname": "display_name", | ||
"fieldtype": "Data", | ||
"label": "Display Name" | ||
} | ||
], | ||
"index_web_pages_for_search": 1, | ||
"links": [ | ||
{ | ||
"group": "Reference", | ||
"link_doctype": "Mail Alias", | ||
"link_fieldname": "alias_for_name" | ||
} | ||
], | ||
"modified": "2025-01-06 15:29:16.465956", | ||
"modified_by": "Administrator", | ||
"module": "Mail", | ||
"name": "Mail Group", | ||
"naming_rule": "Set by user", | ||
"owner": "Administrator", | ||
"permissions": [ | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"export": 1, | ||
"print": 1, | ||
"read": 1, | ||
"report": 1, | ||
"role": "System Manager", | ||
"share": 1, | ||
"write": 1 | ||
} | ||
], | ||
"sort_field": "creation", | ||
"sort_order": "DESC", | ||
"states": [], | ||
"track_changes": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors | ||
# For license information, please see license.txt | ||
|
||
import frappe | ||
from frappe.model.document import Document | ||
|
||
from mail.mail.doctype.mail_agent_job.mail_agent_job import ( | ||
create_group_on_agents, | ||
delete_group_from_agents, | ||
patch_group_on_agents, | ||
) | ||
from mail.utils.validation import ( | ||
is_valid_email_for_domain, | ||
validate_domain_is_enabled_and_verified, | ||
) | ||
|
||
|
||
class MailGroup(Document): | ||
def autoname(self) -> None: | ||
self.email = self.email.strip().lower() | ||
self.name = self.email | ||
|
||
def validate(self) -> None: | ||
self.validate_domain() | ||
self.validate_email() | ||
self.validate_display_name() | ||
|
||
def on_update(self) -> None: | ||
if self.has_value_changed("email"): | ||
create_group_on_agents(self.email, self.display_name) | ||
return | ||
|
||
has_value_changed = self.has_value_changed("display_name") | ||
if has_value_changed: | ||
patch_group_on_agents(self.email, self.display_name) | ||
|
||
def on_trash(self) -> None: | ||
delete_group_from_agents(self.email) | ||
|
||
def validate_domain(self) -> None: | ||
"""Validates the domain.""" | ||
|
||
validate_domain_is_enabled_and_verified(self.domain_name) | ||
|
||
def validate_email(self) -> None: | ||
"""Validates the email address.""" | ||
|
||
is_valid_email_for_domain(self.email, self.domain_name, raise_exception=True) | ||
|
||
def validate_display_name(self) -> None: | ||
"""Validates the display name.""" | ||
|
||
if self.is_new() and not self.display_name: | ||
self.display_name = frappe.db.get_value("User", self.user, "full_name") |
Oops, something went wrong.