From 9424b763cafc94515dd2c04e34948a491216a901 Mon Sep 17 00:00:00 2001 From: ziprandom Date: Tue, 21 Jun 2022 16:02:50 +0000 Subject: [PATCH] POST_CONSUME_SCRIPT: add document dates to env --- docs/advanced_usage.rst | 3 +++ scripts/post-consumption-example.sh | 3 +++ src/documents/consumer.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/docs/advanced_usage.rst b/docs/advanced_usage.rst index bc194ce5a..d32d633b9 100644 --- a/docs/advanced_usage.rst +++ b/docs/advanced_usage.rst @@ -161,6 +161,9 @@ into paperless. It receives the following environment variables: * ``DOCUMENT_ID`` * ``DOCUMENT_FILE_NAME`` +* ``DOCUMENT_CREATED`` +* ``DOCUMENT_MODIFIED`` +* ``DOCUMENT_ADDED`` * ``DOCUMENT_SOURCE_PATH`` * ``DOCUMENT_THUMBNAIL_PATH`` * ``DOCUMENT_DOWNLOAD_URL`` diff --git a/scripts/post-consumption-example.sh b/scripts/post-consumption-example.sh index b4c40090c..81bfa3d48 100755 --- a/scripts/post-consumption-example.sh +++ b/scripts/post-consumption-example.sh @@ -7,6 +7,9 @@ following additional information about it: * Generated File Name: ${DOCUMENT_FILE_NAME} * Source Path: ${DOCUMENT_SOURCE_PATH} +* Created: ${DOCUMENT_CREATED} +* Added: ${DOCUMENT_ADDED} +* Modified: ${DOCUMENT_MODIFIED} * Thumbnail Path: ${DOCUMENT_THUMBNAIL_PATH} * Download URL: ${DOCUMENT_DOWNLOAD_URL} * Thumbnail URL: ${DOCUMENT_THUMBNAIL_URL} diff --git a/src/documents/consumer.py b/src/documents/consumer.py index 42666e107..474f9df8a 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -165,6 +165,9 @@ class Consumer(LoggingMixin): script_env = os.environ.copy() script_env["DOCUMENT_ID"] = str(document.pk) + script_env["DOCUMENT_CREATED"] = str(document.created) + script_env["DOCUMENT_MODIFIED"] = str(document.modified) + script_env["DOCUMENT_ADDED"] = str(document.added) script_env["DOCUMENT_FILE_NAME"] = document.get_public_filename() script_env["DOCUMENT_SOURCE_PATH"] = os.path.normpath(document.source_path) script_env["DOCUMENT_THUMBNAIL_PATH"] = os.path.normpath(