Check that a notification URL is set when sending the test notification (#300)

pull/477/head
dgtlmoon 3 years ago committed by GitHub
parent 489eedf34e
commit 7f8c0fb2fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -452,15 +452,18 @@ def changedetection_app(config=None, datastore_o=None):
update_q.put(uuid)
if form.trigger_check.data:
if len(form.notification_urls.data):
n_object = {'watch_url': form.url.data.strip(),
'notification_urls': form.notification_urls.data,
'notification_title': form.notification_title.data,
'notification_body' : form.notification_body.data,
'notification_format' : form.notification_format.data,
'notification_body': form.notification_body.data,
'notification_format': form.notification_format.data,
}
notification_q.put(n_object)
flash('Test notification queued.')
else:
flash('No notification URLs set, cannot send test.', 'error')
flash('Notifications queued.')
# Diff page [edit] link should go back to diff page
if request.args.get("next") and request.args.get("next") == 'diff':
@ -527,7 +530,8 @@ def changedetection_app(config=None, datastore_o=None):
datastore.data['settings']['application']['notification_urls'] = form.notification_urls.data
datastore.data['settings']['application']['base_url'] = form.base_url.data
if form.trigger_check.data and len(form.notification_urls.data):
if form.trigger_check.data:
if len(form.notification_urls.data):
n_object = {'watch_url': "Test from changedetection.io!",
'notification_urls': form.notification_urls.data,
'notification_title': form.notification_title.data,
@ -535,7 +539,9 @@ def changedetection_app(config=None, datastore_o=None):
'notification_format': form.notification_format.data,
}
notification_q.put(n_object)
flash('Notifications queued.')
flash('Test notification queued.')
else:
flash('No notification URLs set, cannot send test.', 'error')
if form.password.encrypted_password:
datastore.data['settings']['application']['password'] = form.password.encrypted_password

@ -66,7 +66,7 @@ def test_check_notification(client, live_server):
follow_redirects=True
)
assert b"Updated watch." in res.data
assert b"Notifications queued" in res.data
assert b"Test notification queued" in res.data
# Hit the edit page, be sure that we saved it
res = client.get(
@ -136,7 +136,7 @@ def test_check_notification(client, live_server):
)
assert b"Settings updated." in res.data
# Re #143 - should not see this if we didnt hit the test box
assert b"Notifications queued" not in res.data
assert b"Test notification queued" not in res.data
# Trigger a check
client.get(url_for("api_watch_checknow"), follow_redirects=True)

Loading…
Cancel
Save