Skip to content

Commit

Permalink
fix!: require sender and message for contact us page (#34707)
Browse files Browse the repository at this point in the history
* fix: require sender and message for contact us page

* refactor: dont override frappe.send_message from client side

used override_whitelisted_method hook for the same

(cherry picked from commit f193393)
  • Loading branch information
phot0n authored and mergify[bot] committed Apr 5, 2023
1 parent 88c8c36 commit 8fee614
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
4 changes: 4 additions & 0 deletions erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

override_doctype_class = {"Address": "erpnext.accounts.custom.address.ERPNextAddress"}

override_whitelisted_methods = {
"frappe.www.contact.send_message": "erpnext.templates.utils.send_message"
}

welcome_email = "erpnext.setup.utils.welcome_email"

# setup wizard
Expand Down
15 changes: 0 additions & 15 deletions erpnext/public/js/website_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@

if(!window.erpnext) window.erpnext = {};

// Add / update a new Lead / Communication
// subject, sender, description
frappe.send_message = function(opts, btn) {
return frappe.call({
type: "POST",
method: "erpnext.templates.utils.send_message",
btn: btn,
args: opts,
callback: opts.callback
});
};

erpnext.subscribe_to_newsletter = function(opts, btn) {
return frappe.call({
type: "POST",
Expand All @@ -24,6 +12,3 @@ erpnext.subscribe_to_newsletter = function(opts, btn) {
callback: opts.callback
});
}

// for backward compatibility
erpnext.send_message = frappe.send_message;
9 changes: 3 additions & 6 deletions erpnext/templates/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@


@frappe.whitelist(allow_guest=True)
def send_message(subject="Website Query", message="", sender="", status="Open"):
def send_message(sender, message, subject="Website Query"):
from frappe.www.contact import send_message as website_send_message

lead = customer = None

website_send_message(subject, message, sender)
website_send_message(sender, message, subject)

lead = customer = None
customer = frappe.db.sql(
"""select distinct dl.link_name from `tabDynamic Link` dl
left join `tabContact` c on dl.parent=c.name where dl.link_doctype='Customer'
Expand Down Expand Up @@ -58,5 +57,3 @@ def send_message(subject="Website Query", message="", sender="", status="Open"):
}
)
comm.insert(ignore_permissions=True)

return "okay"

0 comments on commit 8fee614

Please sign in to comment.