From 51081941e397a2c6895826d742e1d318f2591ced Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 30 Apr 2025 17:07:44 +0200 Subject: [PATCH] Re #3159 - better send test handling --- changedetectionio/blueprint/ui/notification.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/changedetectionio/blueprint/ui/notification.py b/changedetectionio/blueprint/ui/notification.py index f20fb52715b..1b17f8cb2ce 100644 --- a/changedetectionio/blueprint/ui/notification.py +++ b/changedetectionio/blueprint/ui/notification.py @@ -17,9 +17,9 @@ def ajax_callback_send_notification_test(watch_uuid=None): # Watch_uuid could be unset in the case it`s used in tag editor, global settings import apprise - from changedetectionio.notification.handler import process_notification + import queue + from changedetectionio.update_worker import update_worker from changedetectionio.notification.apprise_plugin.assets import apprise_asset - from changedetectionio.notification.apprise_plugin.custom_handlers import apprise_http_custom_handler apobj = apprise.Apprise(asset=apprise_asset) @@ -92,7 +92,19 @@ def ajax_callback_send_notification_test(watch_uuid=None): n_object['as_async'] = False n_object.update(watch.extra_notification_token_values()) - sent_obj = process_notification(n_object, datastore) + + # Create a temporary notification queue for this test + notification_q = queue.Queue() + + # Create a temporary update_worker instance just for using queue_notification_for_watch + worker = update_worker(queue.Queue(), notification_q, None, datastore) + + # Use queue_notification_for_watch to process the notification with all tokens + worker.queue_notification_for_watch(notification_q, n_object, watch) + + # Get the notification from the queue and process it + from changedetectionio.notification.handler import process_notification + sent_obj = process_notification(notification_q.get(), datastore) except Exception as e: e_str = str(e)