Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: settings: add a check to instantly send email #1061

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"suggest_articles_in_new_ticket_page",
"workflow_tab",
"skip_email_workflow",
"instantly_send_email",
"column_break_aomm",
"misc_tab",
"toasts_column",
Expand Down Expand Up @@ -197,11 +198,17 @@
{
"fieldname": "column_break_aomm",
"fieldtype": "Column Break"
},
{
"default": "0",
"fieldname": "instantly_send_email",
"fieldtype": "Check",
"label": "Instantly send e-mail"
}
],
"issingle": 1,
"links": [],
"modified": "2023-03-14 17:05:08.053813",
"modified": "2023-03-15 21:50:32.939856",
"modified_by": "Administrator",
"module": "FrappeDesk",
"name": "Frappe Desk Settings",
Expand Down
18 changes: 16 additions & 2 deletions frappedesk/frappedesk/doctype/ticket/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ def skip_email_workflow(self):

return bool(int(skip))

def instantly_send_email(self):
check: str = (
frappe.get_value("Frappe Desk Settings", None, "instantly_send_email")
or "0"
)

return bool(int(check))

def last_communication(self):
filters = {"reference_doctype": "Ticket", "reference_name": ["=", self.name]}

Expand Down Expand Up @@ -419,6 +427,12 @@ def reply_via_agent(
"portal_link": self.portal_uri,
"ticket_id": self.name,
}
send_delayed = True
send_now = False

if self.instantly_send_email():
send_delayed = False
send_now = True

try:
frappe.sendmail(
Expand All @@ -427,9 +441,9 @@ def reply_via_agent(
bcc=bcc,
cc=cc,
communication=communication.name,
delayed=False,
delayed=send_delayed,
message=message,
now=True,
now=send_now,
recipients=recipients,
reference_doctype="Ticket",
reference_name=self.name,
Expand Down