perf: process workflow email receipients from background
This commit is contained in:
parent
8344bce09a
commit
b0a4425230
1 changed files with 5 additions and 7 deletions
|
|
@ -109,19 +109,14 @@ def process_workflow_actions(doc, state):
|
|||
return
|
||||
|
||||
roles = {t.allowed for t in next_possible_transitions}
|
||||
user_data_map = get_users_next_action_data(next_possible_transitions, doc)
|
||||
|
||||
if not user_data_map:
|
||||
return
|
||||
|
||||
create_workflow_actions_for_roles(roles, doc)
|
||||
|
||||
if send_email_alert(workflow):
|
||||
enqueue(
|
||||
send_workflow_action_email,
|
||||
queue="short",
|
||||
users_data=list(user_data_map.values()),
|
||||
doc=doc,
|
||||
transitions=next_possible_transitions,
|
||||
enqueue_after_commit=True,
|
||||
)
|
||||
|
||||
|
|
@ -353,6 +348,8 @@ def get_users_next_action_data(transitions, doc):
|
|||
|
||||
|
||||
def create_workflow_actions_for_roles(roles, doc):
|
||||
if not roles:
|
||||
return
|
||||
workflow_action = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Workflow Action",
|
||||
|
|
@ -369,7 +366,8 @@ def create_workflow_actions_for_roles(roles, doc):
|
|||
workflow_action.insert(ignore_permissions=True)
|
||||
|
||||
|
||||
def send_workflow_action_email(users_data, doc):
|
||||
def send_workflow_action_email(doc, transitions):
|
||||
users_data = get_users_next_action_data(transitions, doc)
|
||||
common_args = get_common_email_args(doc)
|
||||
message = common_args.pop("message", None)
|
||||
for d in users_data:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue