diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
index 0f44e0ebd..1db976469 100644
--- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
+++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html
@@ -329,6 +329,7 @@
+
diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts
index 9e1a751c3..56520f9a0 100644
--- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts
+++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts
@@ -414,6 +414,9 @@ export class WorkflowEditDialogComponent
notification_destination_url: new FormControl(
action.notification_destination_url
),
+ notification_destination_url_headers: new FormControl(
+ action.notification_destination_url_headers
+ ),
notification_include_document: new FormControl(
action.notification_include_document
),
@@ -522,6 +525,7 @@ export class WorkflowEditDialogComponent
notification_body: null,
notification_destination_emails: null,
notification_destination_url: null,
+ notification_destination_url_headers: null,
notification_include_document: null,
}
this.object.actions.push(action)
diff --git a/src-ui/src/app/data/workflow-action.ts b/src-ui/src/app/data/workflow-action.ts
index c0bd55d46..096061cd0 100644
--- a/src-ui/src/app/data/workflow-action.ts
+++ b/src-ui/src/app/data/workflow-action.ts
@@ -72,5 +72,7 @@ export interface WorkflowAction extends ObjectWithId {
notification_destination_url?: string
+ notification_destination_url_headers?: string
+
notification_include_document?: boolean
}
diff --git a/src/documents/migrations/1056_workflowaction_notification_body_and_more.py b/src/documents/migrations/1056_workflowaction_notification_body_and_more.py
index e7d8bb908..8f0964292 100644
--- a/src/documents/migrations/1056_workflowaction_notification_body_and_more.py
+++ b/src/documents/migrations/1056_workflowaction_notification_body_and_more.py
@@ -1,4 +1,4 @@
-# Generated by Django 5.1.1 on 2024-10-23 17:15
+# Generated by Django 5.1.2 on 2024-10-26 19:07
from django.db import migrations
from django.db import models
@@ -40,6 +40,16 @@ class Migration(migrations.Migration):
verbose_name="notification destination url",
),
),
+ migrations.AddField(
+ model_name="workflowaction",
+ name="notification_destination_url_headers",
+ field=models.JSONField(
+ blank=True,
+ help_text="The headers to send with the notification destination URL.",
+ null=True,
+ verbose_name="notification destination url headers",
+ ),
+ ),
migrations.AddField(
model_name="workflowaction",
name="notification_include_document",
diff --git a/src/documents/models.py b/src/documents/models.py
index 3225cae55..335fa168d 100644
--- a/src/documents/models.py
+++ b/src/documents/models.py
@@ -1408,6 +1408,13 @@ class WorkflowAction(models.Model):
help_text=_("The destination URL for the notification."),
)
+ notification_destination_url_headers = models.JSONField(
+ _("notification destination url headers"),
+ null=True,
+ blank=True,
+ help_text=_("The headers to send with the notification destination URL."),
+ )
+
notification_include_document = models.BooleanField(
default=False,
verbose_name=_("include document in notification"),
diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py
index 5d209205c..0dc6c28ee 100644
--- a/src/documents/serialisers.py
+++ b/src/documents/serialisers.py
@@ -1851,6 +1851,7 @@ class WorkflowActionSerializer(serializers.ModelSerializer):
"notification_body",
"notification_destination_emails",
"notification_destination_url",
+ "notification_destination_url_headers",
"notification_include_document",
]
diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py
index 10dd5ddcd..773a7522f 100644
--- a/src/documents/signals/handlers.py
+++ b/src/documents/signals/handlers.py
@@ -1,3 +1,4 @@
+import json
import logging
import os
import shutil
@@ -898,7 +899,11 @@ def run_workflows(
)
if action.notification_include_document:
email.attach_file(document.source_path)
- email.send()
+ n_messages = email.send()
+ logger.debug(
+ f"Sent {n_messages} notification email(s) to {action.notification_destination_emails}",
+ extra={"group": logging_group},
+ )
except Exception as e:
logger.exception(
f"Error occurred sending notification email: {e}",
@@ -911,18 +916,37 @@ def run_workflows(
"message": body,
}
files = None
+ headers = None
+ if action.notification_destination_url_headers:
+ try:
+ # headers are a JSON object with key-value pairs, needs to be converted to a Mapping[str, str]
+ header_mapping = json.loads(
+ action.notification_destination_url_headers,
+ )
+ headers = {str(k): str(v) for k, v in header_mapping.items()}
+ except Exception as e:
+ logger.error(
+ f"Error occurred parsing notification destination URL headers: {e}",
+ extra={"group": logging_group},
+ )
if action.notification_include_document:
with open(document.source_path, "rb") as f:
files = {"document": f}
- httpx.post(
+ response = httpx.post(
action.notification_destination_url,
data=data,
+ headers=headers,
files=files,
)
+ logger.debug(
+ f"Response from notification destination URL: {response}",
+ extra={"group": logging_group},
+ )
else:
httpx.post(
action.notification_destination_url,
data=data,
+ headers=headers,
)
except Exception as e:
logger.exception(