mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-11-14 13:36:09 +00:00
Compare commits
1 Commits
send-test-
...
HTML-notif
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
401c4cd092 |
@@ -257,7 +257,6 @@ def process_notification(n_object: NotificationContextData, datastore):
|
|||||||
if n_object.get('markup_text_links_to_html_links'):
|
if n_object.get('markup_text_links_to_html_links'):
|
||||||
n_body = markup_text_links_to_html(body=n_body)
|
n_body = markup_text_links_to_html(body=n_body)
|
||||||
|
|
||||||
|
|
||||||
n_title = jinja_render(template_str=n_object.get('notification_title', ''), **notification_parameters)
|
n_title = jinja_render(template_str=n_object.get('notification_title', ''), **notification_parameters)
|
||||||
|
|
||||||
url = url.strip()
|
url = url.strip()
|
||||||
@@ -279,6 +278,11 @@ def process_notification(n_object: NotificationContextData, datastore):
|
|||||||
from markupsafe import escape
|
from markupsafe import escape
|
||||||
n_body = str(escape(n_body))
|
n_body = str(escape(n_body))
|
||||||
|
|
||||||
|
if 'html' in requested_output_format:
|
||||||
|
# Since the n_body is always some kind of text from the 'diff' engine, attempt to preserve whitespaces that get sent to the HTML output
|
||||||
|
# But only where its more than 1 consecutive whitespace, otherwise "and this" becomes "and this" etc which is too much.
|
||||||
|
n_body = n_body.replace(' ', ' ')
|
||||||
|
|
||||||
(url, n_body, n_title) = apply_service_tweaks(url=url, n_body=n_body, n_title=n_title, requested_output_format=requested_output_format_original)
|
(url, n_body, n_title) = apply_service_tweaks(url=url, n_body=n_body, n_title=n_title, requested_output_format=requested_output_format_original)
|
||||||
|
|
||||||
apprise_input_format = "NO-THANKS-WE-WILL-MANAGE-ALL-OF-THIS"
|
apprise_input_format = "NO-THANKS-WE-WILL-MANAGE-ALL-OF-THIS"
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ def test_check_plaintext_document_html_notifications(client, live_server, measur
|
|||||||
"""When following a plaintext document, notification in Plain Text format is sent correctly"""
|
"""When following a plaintext document, notification in Plain Text format is sent correctly"""
|
||||||
|
|
||||||
with open("test-datastore/endpoint-content.txt", "w") as f:
|
with open("test-datastore/endpoint-content.txt", "w") as f:
|
||||||
f.write("Some nice plain text\nwhich we add some extra data\nover here\n")
|
f.write(" Some nice plain text\nwhich we add some extra data\nover here\n")
|
||||||
|
|
||||||
notification_url = f'mailto://changedetection@{smtp_test_server}:11025/?to=fff@home.com'
|
notification_url = f'mailto://changedetection@{smtp_test_server}:11025/?to=fff@home.com'
|
||||||
notification_body = f"""{default_notification_body}"""
|
notification_body = f"""{default_notification_body}"""
|
||||||
@@ -504,7 +504,7 @@ def test_check_plaintext_document_html_notifications(client, live_server, measur
|
|||||||
|
|
||||||
# Change the content
|
# Change the content
|
||||||
with open("test-datastore/endpoint-content.txt", "w") as f:
|
with open("test-datastore/endpoint-content.txt", "w") as f:
|
||||||
f.write("Some nice plain text\nwhich we add some extra data\nAnd let's talk about <title> tags\nover here\n")
|
f.write(" Some nice plain text\nwhich we add some extra data\nAnd let's talk about <title> tags\nover here\n")
|
||||||
|
|
||||||
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
@@ -544,6 +544,10 @@ def test_check_plaintext_document_html_notifications(client, live_server, measur
|
|||||||
assert '<br>\r\n(added) And let's talk about <title> tags<br>' in html_content
|
assert '<br>\r\n(added) And let's talk about <title> tags<br>' in html_content
|
||||||
assert '<br' not in html_content
|
assert '<br' not in html_content
|
||||||
|
|
||||||
|
# And now for the whitespace retention
|
||||||
|
assert ' Some nice plain text' in html_content
|
||||||
|
assert '(added) And let' in html_content # just to show a single whitespace didnt get touched
|
||||||
|
|
||||||
delete_all_watches(client)
|
delete_all_watches(client)
|
||||||
|
|
||||||
|
|
||||||
@@ -669,6 +673,7 @@ def test_check_html_document_plaintext_notification(client, live_server, measure
|
|||||||
assert '(into) sxome stuff\r\n' in body
|
assert '(into) sxome stuff\r\n' in body
|
||||||
assert '(added) lets slip this in\r\n' in body
|
assert '(added) lets slip this in\r\n' in body
|
||||||
assert '(added) and this in\r\n' in body
|
assert '(added) and this in\r\n' in body
|
||||||
|
assert ' ' not in body
|
||||||
|
|
||||||
|
|
||||||
delete_all_watches(client)
|
delete_all_watches(client)
|
||||||
|
|||||||
Reference in New Issue
Block a user