From 81813548e905bd7c72a230eadd70af46e75e2850 Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Tue, 22 Apr 2025 12:26:47 +0530 Subject: [PATCH] fix(email_queue): remove confirm step No point having 2 steps, if the user has ended up here they do want to send the email. Signed-off-by: Akhil Narang --- .../email/doctype/email_queue/email_queue.js | 18 ++++-------------- .../email/doctype/email_queue/email_queue.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/frappe/email/doctype/email_queue/email_queue.js b/frappe/email/doctype/email_queue/email_queue.js index c1fd674bec..6552f6fc28 100644 --- a/frappe/email/doctype/email_queue/email_queue.js +++ b/frappe/email/doctype/email_queue/email_queue.js @@ -9,26 +9,16 @@ frappe.ui.form.on("Email Queue", { method: "frappe.email.doctype.email_queue.email_queue.send_now", args: { name: frm.doc.name, + force_send: true, }, btn: button, callback: function () { frm.reload_doc(); if (cint(frappe.sys_defaults.suspend_email_queue)) { - // Dialog to confirm if user wants to resume sending emails - frappe.confirm( + frappe.show_alert( __( - "Email Queue is suspended. Do you want to send this email anyway?" - ), - function () { - frappe.call({ - method: - "frappe.email.doctype.email_queue.email_queue.send_now", - args: { - name: frm.doc.name, - force_send: true - }, - }); - } + "Email queue is currently suspended. Resume to automatically send other emails." + ) ); } }, diff --git a/frappe/email/doctype/email_queue/email_queue.py b/frappe/email/doctype/email_queue/email_queue.py index 76c9b9c4d4..836fd927a6 100644 --- a/frappe/email/doctype/email_queue/email_queue.py +++ b/frappe/email/doctype/email_queue/email_queue.py @@ -162,7 +162,12 @@ class EmailQueue(Document): return True - def send(self, smtp_server_instance: SMTPServer = None, frappe_mail_client: FrappeMail = None, force_send = False): + def send( + self, + smtp_server_instance: SMTPServer = None, + frappe_mail_client: FrappeMail = None, + force_send: bool = False, + ): """Send emails to recipients.""" if not self.can_send_now() and not force_send: return @@ -429,6 +434,7 @@ class SendMailContext: file.content = content file.insert() + @frappe.whitelist() def retry_sending(queues: str | list[str]): if not frappe.has_permission("Email Queue", throw=True): @@ -449,11 +455,11 @@ def retry_sending(queues: str | list[str]): @frappe.whitelist() -def send_now(name, force_send=False): +def send_now(name, force_send: bool = False): record = EmailQueue.find(name) if record: record.check_permission() - record.send(force_send = force_send) + record.send(force_send=force_send) @frappe.whitelist()