mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-11-11 09:06:43 -05:00
Fix: use original_file when attaching docs to workflow emails with added trigger (#11266)
This commit is contained in:
parent
906e841ded
commit
a9dfe8f3f7
@ -31,6 +31,8 @@ from guardian.shortcuts import remove_perm
|
|||||||
|
|
||||||
from documents import matching
|
from documents import matching
|
||||||
from documents.caching import clear_document_caches
|
from documents.caching import clear_document_caches
|
||||||
|
from documents.data_models import ConsumableDocument
|
||||||
|
from documents.data_models import DocumentSource
|
||||||
from documents.file_handling import create_source_path_directory
|
from documents.file_handling import create_source_path_directory
|
||||||
from documents.file_handling import delete_empty_directories
|
from documents.file_handling import delete_empty_directories
|
||||||
from documents.file_handling import generate_unique_filename
|
from documents.file_handling import generate_unique_filename
|
||||||
@ -55,7 +57,6 @@ from documents.templating.workflows import parse_w_workflow_placeholders
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from documents.classifier import DocumentClassifier
|
from documents.classifier import DocumentClassifier
|
||||||
from documents.data_models import ConsumableDocument
|
|
||||||
from documents.data_models import DocumentMetadataOverrides
|
from documents.data_models import DocumentMetadataOverrides
|
||||||
|
|
||||||
logger = logging.getLogger("paperless.handlers")
|
logger = logging.getLogger("paperless.handlers")
|
||||||
@ -1163,8 +1164,21 @@ def run_workflows(
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
attachments = []
|
attachments = []
|
||||||
if action.email.include_document and original_file:
|
if action.email.include_document:
|
||||||
attachments = [document]
|
if trigger_type in [
|
||||||
|
WorkflowTrigger.WorkflowTriggerType.DOCUMENT_UPDATED,
|
||||||
|
WorkflowTrigger.WorkflowTriggerType.SCHEDULED,
|
||||||
|
]:
|
||||||
|
# Updated and scheduled can pass the document directly
|
||||||
|
attachments = [document]
|
||||||
|
elif original_file:
|
||||||
|
# For consumed and added document is not yet saved, so pass the original file
|
||||||
|
attachments = [
|
||||||
|
ConsumableDocument(
|
||||||
|
source=DocumentSource.ApiUpload,
|
||||||
|
original_file=original_file,
|
||||||
|
),
|
||||||
|
]
|
||||||
n_messages = send_email(
|
n_messages = send_email(
|
||||||
subject=subject,
|
subject=subject,
|
||||||
body=body,
|
body=body,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user