fix: fetch values from email domain for email account
* chore: remove dead code related to fetching the same
This commit is contained in:
parent
11a17d3867
commit
a3cd00a3ed
2 changed files with 29 additions and 55 deletions
|
|
@ -158,7 +158,6 @@ frappe.ui.form.on("Email Account", {
|
|||
},
|
||||
|
||||
refresh: function (frm) {
|
||||
frm.events.set_domain_fields(frm);
|
||||
frm.events.enable_incoming(frm);
|
||||
frm.events.notify_if_unreplied(frm);
|
||||
frm.events.show_gmail_message_for_less_secure_apps(frm);
|
||||
|
|
@ -211,41 +210,22 @@ frappe.ui.form.on("Email Account", {
|
|||
oauth_access(frm);
|
||||
},
|
||||
|
||||
email_id: function (frm) {
|
||||
//pull domain and if no matching domain go create one
|
||||
frm.events.update_domain(frm);
|
||||
},
|
||||
|
||||
update_domain: function (frm) {
|
||||
if (!frm.doc.email_id && !frm.doc.service) {
|
||||
return;
|
||||
domain: function (frm) {
|
||||
if (frm.doc.domain) {
|
||||
frappe.call({
|
||||
method: "get_domain_values",
|
||||
args: {
|
||||
domain: frm.doc.domain,
|
||||
},
|
||||
callback: function (r) {
|
||||
if (!r.exc) {
|
||||
for (let field in r.message) {
|
||||
frm.set_value(field, r.message[field]);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
frappe.call({
|
||||
method: "get_domain",
|
||||
doc: frm.doc,
|
||||
args: {
|
||||
email_id: frm.doc.email_id,
|
||||
},
|
||||
callback: function (r) {
|
||||
if (r.message) {
|
||||
frm.events.set_domain_fields(frm, r.message);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
set_domain_fields: function (frm, args) {
|
||||
if (!args) {
|
||||
args = frappe.route_flags.set_domain_values ? frappe.route_options : {};
|
||||
}
|
||||
|
||||
for (var field in args) {
|
||||
frm.set_value(field, args[field]);
|
||||
}
|
||||
|
||||
delete frappe.route_flags.set_domain_values;
|
||||
frappe.route_options = {};
|
||||
},
|
||||
|
||||
email_sync_option: function (frm) {
|
||||
|
|
|
|||
|
|
@ -179,26 +179,20 @@ class EmailAccount(Document):
|
|||
email_account.save()
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_domain(self, email_id):
|
||||
"""look-up the domain and then full"""
|
||||
try:
|
||||
domain = email_id.split("@")
|
||||
fields = [
|
||||
"name as domain",
|
||||
"use_imap",
|
||||
"email_server",
|
||||
"use_ssl",
|
||||
"use_starttls",
|
||||
"smtp_server",
|
||||
"use_tls",
|
||||
"smtp_port",
|
||||
"incoming_port",
|
||||
"append_emails_to_sent_folder",
|
||||
"use_ssl_for_outgoing",
|
||||
]
|
||||
return frappe.db.get_value("Email Domain", domain[1], fields, as_dict=True)
|
||||
except Exception:
|
||||
pass
|
||||
def get_domain_values(self, domain: str):
|
||||
fields = [
|
||||
"use_imap",
|
||||
"email_server",
|
||||
"use_ssl",
|
||||
"use_starttls",
|
||||
"smtp_server",
|
||||
"use_tls",
|
||||
"smtp_port",
|
||||
"incoming_port",
|
||||
"append_emails_to_sent_folder",
|
||||
"use_ssl_for_outgoing",
|
||||
]
|
||||
return frappe.db.get_value("Email Domain", domain, fields, as_dict=True)
|
||||
|
||||
def get_incoming_server(self, in_receive=False, email_sync_rule="UNSEEN"):
|
||||
"""Returns logged in POP3/IMAP connection object."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue