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 <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-04-22 12:26:47 +05:30
parent 4848fbda0b
commit 81813548e9
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F
2 changed files with 13 additions and 17 deletions

View file

@ -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."
)
);
}
},

View file

@ -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()