diff --git a/changedetectionio/blueprint/tags/templates/edit-tag.html b/changedetectionio/blueprint/tags/templates/edit-tag.html
index 449ba382..9834f566 100644
--- a/changedetectionio/blueprint/tags/templates/edit-tag.html
+++ b/changedetectionio/blueprint/tags/templates/edit-tag.html
@@ -3,7 +3,7 @@
{% from '_helpers.jinja' import render_field, render_checkbox_field, render_button %}
{% from '_common_fields.jinja' import render_common_settings_form %}
diff --git a/changedetectionio/flask_app.py b/changedetectionio/flask_app.py
index 9345eb9a..21d2c68f 100644
--- a/changedetectionio/flask_app.py
+++ b/changedetectionio/flask_app.py
@@ -485,14 +485,18 @@ def changedetection_app(config=None, datastore_o=None):
# AJAX endpoint for sending a test
+ @app.route("/notification/send-test/", methods=['POST'])
@app.route("/notification/send-test", methods=['POST'])
+ @app.route("/notification/send-test/", methods=['POST'])
@login_optionally_required
- def ajax_callback_send_notification_test():
+ def ajax_callback_send_notification_test(watch_uuid=None):
+ # Watch_uuid could be unsuet in the case its used in tag editor, global setings
import apprise
from .apprise_asset import asset
apobj = apprise.Apprise(asset=asset)
+ watch = datastore.data['watching'].get(watch_uuid) if watch_uuid else None
# validate URLS
if not len(request.form['notification_urls'].strip()):
@@ -505,9 +509,11 @@ def changedetection_app(config=None, datastore_o=None):
return make_response({'error': message}, 400)
try:
- n_object = {'watch_url': request.form['window_url'],
- 'notification_urls': request.form['notification_urls'].splitlines()
- }
+ # use the same as when it is triggered, but then override it with the form test values
+ n_object = {
+ 'watch_url': request.form['window_url'],
+ 'notification_urls': request.form['notification_urls'].splitlines()
+ }
# Only use if present, if not set in n_object it should use the default system value
if 'notification_format' in request.form and request.form['notification_format'].strip():
@@ -519,7 +525,9 @@ def changedetection_app(config=None, datastore_o=None):
if 'notification_body' in request.form and request.form['notification_body'].strip():
n_object['notification_body'] = request.form.get('notification_body', '').strip()
- notification_q.put(n_object)
+ from . import update_worker
+ new_worker = update_worker.update_worker(update_q, notification_q, app, datastore)
+ new_worker.queue_notification_for_watch(notification_q=notification_q, n_object=n_object, watch=watch)
except Exception as e:
return make_response({'error': str(e)}, 400)
diff --git a/changedetectionio/notification.py b/changedetectionio/notification.py
index 93cd304e..c97412d8 100644
--- a/changedetectionio/notification.py
+++ b/changedetectionio/notification.py
@@ -221,13 +221,14 @@ def process_notification(n_object, datastore):
# Notification title + body content parameters get created here.
+# ( Where we prepare the tokens in the notification to be replaced with actual values )
def create_notification_parameters(n_object, datastore):
from copy import deepcopy
# in the case we send a test notification from the main settings, there is no UUID.
uuid = n_object['uuid'] if 'uuid' in n_object else ''
- if uuid != '':
+ if uuid:
watch_title = datastore.data['watching'][uuid].get('title', '')
tag_list = []
tags = datastore.get_all_tags_for_watch(uuid)
@@ -255,7 +256,7 @@ def create_notification_parameters(n_object, datastore):
tokens.update(
{
'base_url': base_url,
- 'current_snapshot': n_object['current_snapshot'] if 'current_snapshot' in n_object else '',
+ 'current_snapshot': n_object.get('current_snapshot', ''),
'diff': n_object.get('diff', ''), # Null default in the case we use a test
'diff_added': n_object.get('diff_added', ''), # Null default in the case we use a test
'diff_full': n_object.get('diff_full', ''), # Null default in the case we use a test
diff --git a/changedetectionio/static/js/notifications.js b/changedetectionio/static/js/notifications.js
index 6b855b18..046b645c 100644
--- a/changedetectionio/static/js/notifications.js
+++ b/changedetectionio/static/js/notifications.js
@@ -24,14 +24,17 @@ $(document).ready(function() {
})
data = {
- window_url : window.location.href,
- notification_urls : $('.notification-urls').val(),
+ notification_body: $('#notification_body').val(),
+ notification_format: $('#notification_format').val(),
+ notification_title: $('#notification_title').val(),
+ notification_urls: $('.notification-urls').val(),
+ window_url: window.location.href,
}
- for (key in data) {
- if (!data[key].length) {
- alert(key+" is empty, cannot send test.")
- return;
- }
+
+
+ if (!data['notification_urls'].length) {
+ alert("Notification URL list is empty, cannot send test.")
+ return;
}
$.ajax({
diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html
index 103f57af..d43ed666 100644
--- a/changedetectionio/templates/edit.html
+++ b/changedetectionio/templates/edit.html
@@ -14,7 +14,7 @@
{% if emailprefix %}
const email_notification_prefix=JSON.parse('{{ emailprefix|tojson }}');
{% endif %}
- const notification_base_url="{{url_for('ajax_callback_send_notification_test')}}";
+ const notification_base_url="{{url_for('ajax_callback_send_notification_test', watch_uuid=uuid)}}";
const playwright_enabled={% if playwright_enabled %} true {% else %} false {% endif %};
const recheck_proxy_start_url="{{url_for('check_proxies.start_check', uuid=uuid)}}";
const proxy_recheck_status_url="{{url_for('check_proxies.get_recheck_status', uuid=uuid)}}";
diff --git a/changedetectionio/templates/settings.html b/changedetectionio/templates/settings.html
index ef93069e..508f49b2 100644
--- a/changedetectionio/templates/settings.html
+++ b/changedetectionio/templates/settings.html
@@ -4,7 +4,7 @@
{% from '_helpers.jinja' import render_field, render_checkbox_field, render_button %}
{% from '_common_fields.jinja' import render_common_settings_form %}