Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Jan 7, 2025
1 parent db158b1 commit 6bd2044
Show file tree
Hide file tree
Showing 14 changed files with 505 additions and 295 deletions.
4 changes: 2 additions & 2 deletions mail/api/auth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import frappe
from frappe import _

from mail.utils.user import has_role, is_mailbox_owner
from mail.utils.user import has_role, is_mail_account_owner
from mail.utils.validation import (
validate_mailbox_for_incoming,
validate_mailbox_for_outgoing,
Expand Down Expand Up @@ -37,7 +37,7 @@ def validate_mailbox(mailbox: str) -> None:

user = frappe.session.user

if not is_mailbox_owner(mailbox, user):
if not is_mail_account_owner(mailbox, user):
frappe.throw(
_("Mailbox {0} is not associated with user {1}").format(frappe.bold(mailbox), frappe.bold(user))
)
4 changes: 2 additions & 2 deletions mail/mail/doctype/incoming_mail/incoming_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from mail.utils.cache import get_postmaster_for_domain
from mail.utils.dt import add_or_update_tzinfo, parse_iso_datetime
from mail.utils.email_parser import EmailParser, extract_ip_and_host
from mail.utils.user import get_user_mailboxes, is_mailbox_owner, is_system_manager
from mail.utils.user import get_user_mailboxes, is_mail_account_owner, is_system_manager

if TYPE_CHECKING:
from mail.mail.doctype.outgoing_mail.outgoing_mail import OutgoingMail
Expand Down Expand Up @@ -221,7 +221,7 @@ def has_permission(doc: "Document", ptype: str, user: str) -> bool:
return False

user_is_system_manager = is_system_manager(user)
user_is_mailbox_owner = is_mailbox_owner(doc.receiver, user)
user_is_mailbox_owner = is_mail_account_owner(doc.receiver, user)

if ptype in ["create", "submit"]:
return user_is_system_manager
Expand Down
12 changes: 11 additions & 1 deletion mail/mail/doctype/mail_account/mail_account.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,19 @@
"group": "Reference",
"link_doctype": "Mail Group Member",
"link_fieldname": "member_name"
},
{
"group": "Mail",
"link_doctype": "Incoming Mail",
"link_fieldname": "receiver"
},
{
"group": "Mail",
"link_doctype": "Outgoing Mail",
"link_fieldname": "sender"
}
],
"modified": "2025-01-06 18:20:48.241975",
"modified": "2025-01-07 17:19:31.813542",
"modified_by": "Administrator",
"module": "Mail",
"name": "Mail Account",
Expand Down
54 changes: 52 additions & 2 deletions mail/mail/doctype/mail_domain/mail_domain.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@
"dkim_rsa_key_size",
"newsletter_retention",
"dns_records_section",
"dns_records"
"dns_records",
"agent_groups_section",
"include_agent_groups",
"column_break_vpyy",
"exclude_agent_groups",
"agents_section",
"include_agents",
"column_break_x6bd",
"exclude_agents"
],
"fields": [
{
Expand Down Expand Up @@ -86,6 +94,48 @@
"fieldtype": "Select",
"label": "DKIM RSA Key Size",
"options": "\n2048\n4096"
},
{
"collapsible": 1,
"collapsible_depends_on": "eval: doc.include_agents || doc.exclude_agents",
"fieldname": "agents_section",
"fieldtype": "Section Break",
"label": "Agents"
},
{
"fieldname": "include_agents",
"fieldtype": "Small Text",
"label": "Include Agents"
},
{
"fieldname": "column_break_x6bd",
"fieldtype": "Column Break"
},
{
"fieldname": "exclude_agents",
"fieldtype": "Small Text",
"label": "Exclude Agents"
},
{
"collapsible": 1,
"collapsible_depends_on": "eval: doc.include_agent_groups || doc.exclude_agent_groups",
"fieldname": "agent_groups_section",
"fieldtype": "Section Break",
"label": "Agent Groups"
},
{
"fieldname": "include_agent_groups",
"fieldtype": "Small Text",
"label": "Include Agent Groups"
},
{
"fieldname": "column_break_vpyy",
"fieldtype": "Column Break"
},
{
"fieldname": "exclude_agent_groups",
"fieldtype": "Small Text",
"label": "Exclude Agent Groups"
}
],
"index_web_pages_for_search": 1,
Expand Down Expand Up @@ -126,7 +176,7 @@
"link_fieldname": "domain_name"
}
],
"modified": "2025-01-06 15:35:35.811831",
"modified": "2025-01-07 17:15:28.361921",
"modified_by": "Administrator",
"module": "Mail",
"name": "Mail Domain",
Expand Down
83 changes: 76 additions & 7 deletions mail/mail/doctype/mail_settings/mail_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@
"default_newsletter_retention",
"column_break_rwnw",
"default_ttl",
"limits_section",
"limits_tab",
"max_recipients",
"max_headers",
"column_break_seja",
"max_message_size_mb",
"max_newsletter_retention",
"section_break_m7bg",
"max_attachments",
"column_break_4lt9",
"max_attachment_size_mb",
"max_total_attachments_size_mb",
"spamassassin_tab",
"section_break_hgqa",
"enable_spamd",
Expand Down Expand Up @@ -193,24 +202,84 @@
"non_negative": 1,
"reqd": 1
},
{
"fieldname": "limits_section",
"fieldtype": "Section Break",
"label": "Limits"
},
{
"default": "2048",
"fieldname": "default_dkim_rsa_key_size",
"fieldtype": "Select",
"label": "DKIM RSA Key Size",
"options": "\n2048\n4096",
"reqd": 1
},
{
"default": "25",
"fieldname": "max_recipients",
"fieldtype": "Int",
"label": "Maximum Number of Recipients",
"non_negative": 1,
"reqd": 1
},
{
"default": "15",
"fieldname": "max_message_size_mb",
"fieldtype": "Int",
"label": "Maximum Message Size (MB)",
"non_negative": 1,
"reqd": 1
},
{
"default": "10",
"fieldname": "max_headers",
"fieldtype": "Int",
"label": "Maximum Custom Headers",
"non_negative": 1,
"reqd": 1
},
{
"default": "10",
"fieldname": "max_attachment_size_mb",
"fieldtype": "Int",
"label": "Maximum Attachment Size (MB)",
"non_negative": 1,
"reqd": 1
},
{
"default": "10",
"fieldname": "max_total_attachments_size_mb",
"fieldtype": "Int",
"label": "Maximum Total Attachments Size (MB)",
"non_negative": 1,
"reqd": 1
},
{
"fieldname": "limits_tab",
"fieldtype": "Tab Break",
"label": "Limits"
},
{
"fieldname": "column_break_seja",
"fieldtype": "Column Break"
},
{
"fieldname": "section_break_m7bg",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_4lt9",
"fieldtype": "Column Break"
},
{
"default": "10",
"fieldname": "max_attachments",
"fieldtype": "Int",
"label": "Maximum Number of Attachments",
"non_negative": 1,
"reqd": 1
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2025-01-05 12:06:02.282670",
"modified": "2025-01-07 15:14:39.981167",
"modified_by": "Administrator",
"module": "Mail",
"name": "Mail Settings",
Expand Down
9 changes: 7 additions & 2 deletions mail/mail/doctype/mime_message/mime_message.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,20 @@
{
"group": "Reference",
"link_doctype": "Outgoing Mail",
"link_fieldname": "message"
"link_fieldname": "_message"
},
{
"group": "Reference",
"link_doctype": "Outgoing Mail",
"link_fieldname": "_raw_message"
},
{
"group": "Reference",
"link_doctype": "Spam Check Log",
"link_fieldname": "_message"
}
],
"modified": "2025-01-07 12:51:54.162433",
"modified": "2025-01-07 17:20:05.618459",
"modified_by": "Administrator",
"module": "Mail",
"name": "MIME Message",
Expand Down
32 changes: 4 additions & 28 deletions mail/mail/doctype/outgoing_mail/outgoing_mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ frappe.ui.form.on("Outgoing Mail", {

add_actions(frm) {
if (frm.doc.docstatus === 1) {
if (frm.doc.status === "Pending") {
if (frm.doc.status === "In Progress") {
frm.add_custom_button(
__("Transfer Now"),
() => {
frm.trigger("transfer_to_mail_server");
frm.trigger("transfer_to_mail_agent");
},
__("Actions")
);
Expand All @@ -43,14 +43,6 @@ frappe.ui.form.on("Outgoing Mail", {
},
__("Actions")
);
} else if (["Queued", "Deferred"].includes(frm.doc.status)) {
frm.add_custom_button(
__("Fetch Delivery Status"),
() => {
frm.trigger("fetch_and_update_delivery_statuses");
},
__("Actions")
);
} else if (frm.doc.status === "Sent") {
frm.add_custom_button(
__("Reply"),
Expand Down Expand Up @@ -89,10 +81,10 @@ frappe.ui.form.on("Outgoing Mail", {
}
},

transfer_to_mail_server(frm) {
transfer_to_mail_agent(frm) {
frappe.call({
doc: frm.doc,
method: "transfer_to_mail_server",
method: "transfer_to_mail_agent",
freeze: true,
freeze_message: __("Transferring..."),
callback: (r) => {
Expand All @@ -117,22 +109,6 @@ frappe.ui.form.on("Outgoing Mail", {
});
},

fetch_and_update_delivery_statuses(frm) {
frappe.call({
method: "mail.tasks.enqueue_fetch_and_update_delivery_statuses",
freeze: true,
freeze_message: __("Creating Job..."),
callback: () => {
frappe.show_alert({
message: __("{0} job has been created.", [
__("Fetch Delivery Statuses").bold(),
]),
indicator: "green",
});
},
});
},

reply(frm) {
frappe.model.open_mapped_doc({
method: "mail.mail.doctype.outgoing_mail.outgoing_mail.reply_to_mail",
Expand Down
Loading

0 comments on commit 6bd2044

Please sign in to comment.