diff --git a/bazarr/main.py b/bazarr/main.py index 21faa9e56..5fb588894 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -83,7 +83,6 @@ def check_credentials(user, pw): def login_required(f): @wraps(f) def wrap(*args, **kwargs): - test = request if settings.auth.type == 'basic': auth = request.authorization if not (auth and check_credentials(request.authorization.username, request.authorization.password)): @@ -151,7 +150,6 @@ def post_get(name, default=''): @app.route("/logout/") @login_required def logout(): - test = settings.auth.type if settings.auth.type == 'basic': return abort(401) elif settings.auth.type == 'form': @@ -484,6 +482,7 @@ def test_url(protocol, url): return dict(status=False, error=result.raise_for_status()) +@app.route('/test_notification', methods=['GET']) @app.route('/test_notification//', methods=['GET']) @login_required def test_notification(protocol, provider): @@ -497,6 +496,8 @@ def test_notification(protocol, provider): body='Test notification' ) + return '', 200 + # Mute DeprecationWarning warnings.simplefilter("ignore", DeprecationWarning) diff --git a/views/settingsnotifications.html b/views/settingsnotifications.html index 42fb42d1a..817a9b1ec 100644 --- a/views/settingsnotifications.html +++ b/views/settingsnotifications.html @@ -95,6 +95,7 @@ @@ -212,6 +213,23 @@ }); }); + $('#test_button').on('click', function() { + const url_field = $('#notification_provider_url').val(); + const url_protocol = url_field.split(':')[0]; + const url_string = url_field.split('://')[1]; + + $.ajax({ + url: "{{ url_for('test_notification') }}/" + url_protocol + "/" + encodeURIComponent(url_string), + beforeSend: function () { + $('#loader').addClass('active'); + }, + complete: function () { + $('#loader').removeClass('active'); + }, + cache: false + }); + }); + // monitor changes to the settings_form $('#settings_form').on('change', function() { form_changed = true;