diff --git a/backend/__init__.py b/backend/__init__.py index a81d324d..25e06049 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -798,8 +798,15 @@ def notification_runner(): for url in n_object['notification_urls']: apobj.add(url.strip()) + n_body = n_object['watch_url'] + + # 65 - Append URL of instance to the notification if it is set. + base_url = os.getenv('BASE_URL') + if base_url != None: + n_body += "\n" + base_url + apobj.notify( - body=n_object['watch_url'], + body=n_body, # @todo This should be configurable. title="ChangeDetection.io Notification - {}".format(n_object['watch_url']) ) diff --git a/backend/run_all_tests.sh b/backend/run_all_tests.sh index 43c487ce..d4eb38e3 100755 --- a/backend/run_all_tests.sh +++ b/backend/run_all_tests.sh @@ -9,6 +9,9 @@ # exit when any command fails set -e +# Re #65 - Ability to include a link back to the installation, in the notification. +export BASE_URL="https://foobar.com" + find tests/test_*py -type f|while read test_name do echo "TEST RUNNING $test_name" diff --git a/backend/tests/test_notification.py b/backend/tests/test_notification.py index e079865b..62a70260 100644 --- a/backend/tests/test_notification.py +++ b/backend/tests/test_notification.py @@ -54,6 +54,7 @@ def test_check_notification(client, live_server): # Did the front end see it? res = client.get( url_for("index")) + assert bytes("just now".encode('utf-8')) in res.data @@ -61,6 +62,11 @@ def test_check_notification(client, live_server): res = client.get( url_for("test_notification_counter"), ) - print (res.data) assert bytes("we hit it".encode('utf-8')) in res.data + + # Did we see the URL that had a change, in the notification? + assert bytes("test-endpoint".encode('utf-8')) in res.data + + # Re #65 - did we see our foobar.com BASE_URL ? + assert bytes("https://foobar.com".encode('utf-8')) in res.data diff --git a/backend/tests/util.py b/backend/tests/util.py index 6f655991..8a14ee63 100644 --- a/backend/tests/util.py +++ b/backend/tests/util.py @@ -43,8 +43,15 @@ def live_server_setup(live_server): @live_server.app.route('/test_notification_endpoint', methods=['POST']) def test_notification_endpoint(): + from flask import request + with open("test-datastore/count.txt", "w") as f: - f.write("we hit it") + f.write("we hit it\n") + # Debug method, dump all POST to file also, used to prove #65 + data = request.stream.read() + if data != None: + f.write(str(data)) + print("\n>> Test notification endpoint was hit.\n") return "Text was set" diff --git a/docker-compose.yml b/docker-compose.yml index 9ef04e0b..bcb69e75 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,12 +7,14 @@ services: volumes: - changedetection-data:/datastore - # Proxy support example. # environment: + # Proxy support example. # - HTTP_PROXY="socks5h://10.10.1.10:1080" # - HTTPS_PROXY="socks5h://10.10.1.10:1080" - # An exclude list (useful for notifcation URLs above) can be specified by following + # An exclude list (useful for notification URLs above) can be specified by with # - NO_PROXY="localhost,192.168.0.0/24" + # Base URL of your changedetection.io install (Added to notification alert + # - BASE_URL="https://mysite.com" ports: - 5000:5000