From 550c2bee0ce0a8b85665727a50e0f2b6dcee3e59 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 30 Oct 2025 16:58:55 +0100 Subject: [PATCH] Notifications - Adding {{diff_full_clean}}, {{diff_removed_clean}}, {{diff_added_clean}}, {{diff_clean}} notification body tokens for using in templates without (added)/(removed) text. --- changedetectionio/notification_service.py | 8 ++++++++ changedetectionio/templates/_common_fields.html | 16 ++++++++++++++++ .../tests/smtp/test_notification_smtp.py | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/changedetectionio/notification_service.py b/changedetectionio/notification_service.py index 4cf3bd4a3..c0a09e98c 100644 --- a/changedetectionio/notification_service.py +++ b/changedetectionio/notification_service.py @@ -20,10 +20,14 @@ class NotificationContextData(dict): 'base_url': None, 'current_snapshot': None, 'diff': None, + 'diff_clean': None, 'diff_added': None, + 'diff_added_clean': None, 'diff_full': None, + 'diff_full_clean': None, 'diff_patch': None, 'diff_removed': None, + 'diff_removed_clean': None, 'diff_url': None, 'markup_text_links_to_html_links': False, # If automatic conversion of plaintext to HTML should happen 'notification_timestamp': time.time(), @@ -76,10 +80,14 @@ def set_basic_notification_vars(snapshot_contents, current_snapshot, prev_snapsh n_object = { 'current_snapshot': snapshot_contents, 'diff': diff.render_diff(prev_snapshot, current_snapshot), + 'diff_clean': diff.render_diff(prev_snapshot, current_snapshot, include_change_type_prefix=False), 'diff_added': diff.render_diff(prev_snapshot, current_snapshot, include_removed=False), + 'diff_added_clean': diff.render_diff(prev_snapshot, current_snapshot, include_removed=False, include_change_type_prefix=False), 'diff_full': diff.render_diff(prev_snapshot, current_snapshot, include_equal=True), + 'diff_full_clean': diff.render_diff(prev_snapshot, current_snapshot, include_equal=True, include_change_type_prefix=False), 'diff_patch': diff.render_diff(prev_snapshot, current_snapshot, patch_format=True), 'diff_removed': diff.render_diff(prev_snapshot, current_snapshot, include_added=False), + 'diff_removed_clean': diff.render_diff(prev_snapshot, current_snapshot, include_added=False, include_change_type_prefix=False), 'screenshot': watch.get_screenshot() if watch and watch.get('notification_screenshot') else None, 'triggered_text': triggered_text, 'uuid': watch.get('uuid') if watch else None, diff --git a/changedetectionio/templates/_common_fields.html b/changedetectionio/templates/_common_fields.html index 874dca562..70dabaf29 100644 --- a/changedetectionio/templates/_common_fields.html +++ b/changedetectionio/templates/_common_fields.html @@ -87,19 +87,35 @@ {{ '{{diff}}' }} The diff output - only changes, additions, and removals + + + {{ '{{diff_clean}}' }} + The diff output - only changes, additions, and removals ‐ Without (added) prefix or colors {{ '{{diff_added}}' }} The diff output - only changes and additions + + + {{ '{{diff_added_clean}}' }} + The diff output - only changes and additions ‐ Without (added) prefix or colors {{ '{{diff_removed}}' }} The diff output - only changes and removals + + + {{ '{{diff_removed_clean}}' }} + The diff output - only changes and removals ‐ Without (added) prefix or colors {{ '{{diff_full}}' }} The diff output - full difference output + + {{ '{{diff_full_clean}}' }} + The diff output - full difference output ‐ Without (added) prefix or colors + {{ '{{diff_patch}}' }} The diff output - patch in unified format diff --git a/changedetectionio/tests/smtp/test_notification_smtp.py b/changedetectionio/tests/smtp/test_notification_smtp.py index c391f5240..c8bab3712 100644 --- a/changedetectionio/tests/smtp/test_notification_smtp.py +++ b/changedetectionio/tests/smtp/test_notification_smtp.py @@ -14,7 +14,7 @@ import logging # NOTE - RELIES ON mailserver as hostname running, see github build recipes -smtp_test_server = 'mailserver' +smtp_test_server = 'localhost' ALL_MARKUP_TOKENS = ''.join(f"TOKEN: '{t}'\n{{{{{t}}}}}\n" for t in NotificationContextData().keys())