From 63366a0a83b49b639a40a9f1ae282c1c32f35dee Mon Sep 17 00:00:00 2001 From: mikebgrep Date: Sun, 20 Oct 2024 14:06:58 +0300 Subject: [PATCH 1/3] add if None for watch in queue_notification_for_watch --- changedetectionio/update_worker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index 9dd460d3..af54eff4 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -81,7 +81,8 @@ class update_worker(threading.Thread): 'watch_url': watch.get('url') if watch else None, }) - n_object.update(watch.extra_notification_token_values()) + if watch: + n_object.update(watch.extra_notification_token_values()) logger.trace(f"Main rendered notification placeholders (diff_added etc) calculated in {time.time()-now:.3f}s") logger.debug("Queued notification for sending") From d82f254382599e6ee0dda01731c4dbc85fa2f639 Mon Sep 17 00:00:00 2001 From: mikebgrep Date: Sun, 20 Oct 2024 14:07:49 +0300 Subject: [PATCH 2/3] fix typo, add additional condition for if when wathing are len() < 0 --- changedetectionio/flask_app.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/changedetectionio/flask_app.py b/changedetectionio/flask_app.py index 705ea20d..027581d1 100644 --- a/changedetectionio/flask_app.py +++ b/changedetectionio/flask_app.py @@ -67,7 +67,6 @@ FlaskCompress(app) # Stop browser caching of assets app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 - app.config.exit = Event() app.config['NEW_VERSION_AVAILABLE'] = False @@ -470,7 +469,7 @@ def changedetection_app(config=None, datastore_o=None): continue if watch.get('last_error'): errored_count += 1 - + if search_q: if (watch.get('title') and search_q in watch.get('title').lower()) or search_q in watch.get('url', '').lower(): sorted_watches.append(watch) @@ -533,7 +532,7 @@ def changedetection_app(config=None, datastore_o=None): @login_optionally_required def ajax_callback_send_notification_test(watch_uuid=None): - # Watch_uuid could be unset in the case its used in tag editor, global setings + # Watch_uuid could be unset in the case it`s used in tag editor, global settings import apprise import random from .apprise_asset import asset @@ -542,13 +541,15 @@ def changedetection_app(config=None, datastore_o=None): from changedetectionio.apprise_plugin import apprise_custom_api_call_wrapper is_global_settings_form = request.args.get('mode', '') == 'global-settings' is_group_settings_form = request.args.get('mode', '') == 'group-settings' - # Use an existing random one on the global/main settings form - if not watch_uuid and (is_global_settings_form or is_group_settings_form): + if not watch_uuid and (is_global_settings_form or is_group_settings_form) \ + and len(list(datastore.data['watching'].keys())) > 0: + logger.debug(f"Send test notification - Choosing random Watch {watch_uuid}") watch_uuid = random.choice(list(datastore.data['watching'].keys())) - - watch = datastore.data['watching'].get(watch_uuid) + watch = datastore.data['watching'].get(watch_uuid) + else: + watch = None notification_urls = request.form['notification_urls'].strip().splitlines() @@ -1396,7 +1397,7 @@ def changedetection_app(config=None, datastore_o=None): url = request.form.get('url').strip() if datastore.url_exists(url): flash(f'Warning, URL {url} already exists', "notice") - + add_paused = request.form.get('edit_and_watch_submit_button') != None processor = request.form.get('processor', 'text_json_diff') new_uuid = datastore.add_watch(url=url, tag=request.form.get('tags').strip(), extras={'paused': add_paused, 'processor': processor}) From a1d818654629d8970ab0795ca740b6370fb54559 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 21 Oct 2024 09:32:02 +0200 Subject: [PATCH 3/3] Update changedetectionio/flask_app.py --- changedetectionio/flask_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changedetectionio/flask_app.py b/changedetectionio/flask_app.py index 027581d1..a1bb862e 100644 --- a/changedetectionio/flask_app.py +++ b/changedetectionio/flask_app.py @@ -543,7 +543,7 @@ def changedetection_app(config=None, datastore_o=None): is_group_settings_form = request.args.get('mode', '') == 'group-settings' # Use an existing random one on the global/main settings form if not watch_uuid and (is_global_settings_form or is_group_settings_form) \ - and len(list(datastore.data['watching'].keys())) > 0: + and datastore.data.get('watching'): logger.debug(f"Send test notification - Choosing random Watch {watch_uuid}") watch_uuid = random.choice(list(datastore.data['watching'].keys()))