Skip to content

Commit fe4963e

Browse files
authored
Re #143 - Remove old notification test code, fix form handler (#145)
* Re #143 - global notification settings box fix - Remove old notification test code, fix form handler, add test
1 parent 32a7981 commit fe4963e

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

backend/__init__.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -486,29 +486,10 @@ def settings_page():
486486
datastore.data['settings']['application']['notification_title'] = form.notification_title.data
487487
datastore.data['settings']['application']['notification_body'] = form.notification_body.data
488488

489-
if len(form.notification_urls.data):
490-
import apprise
491-
apobj = apprise.Apprise()
492-
apobj.debug = True
493-
494-
# Add each notification
495-
for n in datastore.data['settings']['application']['notification_urls']:
496-
apobj.add(n)
497-
outcome = apobj.notify(
498-
body='Hello from the worlds best and simplest web page change detection and monitoring service!',
499-
title='Changedetection.io Notification Test',
500-
)
501-
502-
if outcome:
503-
flash("{} Notification URLs reached.".format(len(form.notification_urls.data)), "notice")
504-
else:
505-
flash("One or more Notification URLs failed", 'error')
506-
507-
508489
datastore.data['settings']['application']['notification_urls'] = form.notification_urls.data
509490
datastore.needs_write = True
510491

511-
if form.trigger_check.data:
492+
if form.trigger_check.data and len(form.notification_urls.data):
512493
n_object = {'watch_url': "Test from changedetection.io!",
513494
'notification_urls': form.notification_urls.data}
514495
notification_q.put(n_object)

backend/templates/settings.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,9 @@
8686
</span>
8787
</div>
8888
</div>
89-
90-
<span class="pure-form-message-inline"><label for="trigger-test-notification" class="pure-checkbox">
91-
<input type="checkbox" id="trigger-test-notification" name="trigger-test-notification"> Send test notification on save.</label>
92-
</span>
93-
89+
<div class="pure-control-group">
90+
{{ render_field(form.trigger_check) }}
91+
</div>
9492
</div>
9593
<div class="pure-control-group">
9694
<button type="submit" class="pure-button pure-button-primary">Save</button>

backend/tests/test_notification.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@ def test_check_notification(client, live_server):
9494
url_for("settings_page"),
9595
data={"notification_title": "New ChangeDetection.io Notification - {watch_url}",
9696
"notification_body": "{base_url}\n{watch_url}\n{preview_url}\n{diff_url}\n{current_snapshot}\n:-)",
97+
"notification_urls": "json://foobar.com", #Re #143 should not see that it sent without [test checkbox]
9798
"minutes_between_check": 180},
9899
follow_redirects=True
99100
)
100101
assert b"Settings updated." in res.data
102+
# Re #143 - should not see this if we didnt hit the test box
103+
assert b"Notifications queued" not in res.data
101104

102105
# Trigger a check
103106
client.get(url_for("api_watch_checknow"), follow_redirects=True)

0 commit comments

Comments
 (0)