Move email backend check to execute_email_action for consistency

This commit is contained in:
shamoon
2025-12-09 09:53:18 -08:00
parent 827c3da1be
commit 1083021e7a
3 changed files with 8 additions and 8 deletions

View File

@@ -731,13 +731,6 @@ def run_workflows(
else:
apply_removal_to_document(action, document, doc_tag_ids)
elif action.type == WorkflowAction.WorkflowActionType.EMAIL:
if not settings.EMAIL_ENABLED:
logger.error(
"Email backend has not been configured, cannot send email notifications",
extra={"group": logging_group},
)
continue
context = build_workflow_action_context(document, overrides)
execute_email_action(
action,

View File

@@ -3096,7 +3096,7 @@ class TestWorkflows(
original_filename="sample.pdf",
)
with self.assertLogs("paperless.handlers", level="ERROR") as cm:
with self.assertLogs("paperless.workflows.actions", level="ERROR") as cm:
run_workflows(WorkflowTrigger.WorkflowTriggerType.DOCUMENT_UPDATED, doc)
expected_str = "Email backend has not been configured"

View File

@@ -90,6 +90,13 @@ def execute_email_action(
Execute an email action for a workflow.
"""
if not settings.EMAIL_ENABLED:
logger.error(
"Email backend has not been configured, cannot send email notifications",
extra={"group": logging_group},
)
return
subject = (
parse_w_workflow_placeholders(
action.email.subject,