kopia lustrzana https://github.com/dgtlmoon/changedetection.io
2742-notification-headers-encoding
rodzic
b0ff9d161e
commit
82e0b99b07
|
@ -67,7 +67,6 @@ FlaskCompress(app)
|
||||||
|
|
||||||
# Stop browser caching of assets
|
# Stop browser caching of assets
|
||||||
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
|
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
|
||||||
|
|
||||||
app.config.exit = Event()
|
app.config.exit = Event()
|
||||||
|
|
||||||
app.config['NEW_VERSION_AVAILABLE'] = False
|
app.config['NEW_VERSION_AVAILABLE'] = False
|
||||||
|
@ -533,7 +532,7 @@ def changedetection_app(config=None, datastore_o=None):
|
||||||
@login_optionally_required
|
@login_optionally_required
|
||||||
def ajax_callback_send_notification_test(watch_uuid=None):
|
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 apprise
|
||||||
import random
|
import random
|
||||||
from .apprise_asset import asset
|
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
|
from changedetectionio.apprise_plugin import apprise_custom_api_call_wrapper
|
||||||
is_global_settings_form = request.args.get('mode', '') == 'global-settings'
|
is_global_settings_form = request.args.get('mode', '') == 'global-settings'
|
||||||
is_group_settings_form = request.args.get('mode', '') == 'group-settings'
|
is_group_settings_form = request.args.get('mode', '') == 'group-settings'
|
||||||
|
|
||||||
# Use an existing random one on the global/main settings form
|
# 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 datastore.data.get('watching'):
|
||||||
|
|
||||||
logger.debug(f"Send test notification - Choosing random Watch {watch_uuid}")
|
logger.debug(f"Send test notification - Choosing random Watch {watch_uuid}")
|
||||||
watch_uuid = random.choice(list(datastore.data['watching'].keys()))
|
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()
|
notification_urls = request.form['notification_urls'].strip().splitlines()
|
||||||
|
|
||||||
|
|
|
@ -429,3 +429,24 @@ def test_global_send_test_notification(client, live_server, measure_memory_usage
|
||||||
follow_redirects=True
|
follow_redirects=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#2727 - be sure a test notification when there are zero watches works ( should all be deleted now)
|
||||||
|
|
||||||
|
os.unlink("test-datastore/notification.txt")
|
||||||
|
|
||||||
|
|
||||||
|
######### Test global/system settings
|
||||||
|
res = client.post(
|
||||||
|
url_for("ajax_callback_send_notification_test")+"?mode=global-settings",
|
||||||
|
data={"notification_urls": test_notification_url},
|
||||||
|
follow_redirects=True
|
||||||
|
)
|
||||||
|
|
||||||
|
assert res.status_code != 400
|
||||||
|
assert res.status_code != 500
|
||||||
|
|
||||||
|
# Give apprise time to fire
|
||||||
|
time.sleep(4)
|
||||||
|
|
||||||
|
with open("test-datastore/notification.txt", 'r') as f:
|
||||||
|
x = f.read()
|
||||||
|
assert 'change detection is cool 网站监测 内容更新了' in x
|
||||||
|
|
|
@ -81,6 +81,7 @@ class update_worker(threading.Thread):
|
||||||
'watch_url': watch.get('url') if watch else None,
|
'watch_url': watch.get('url') if watch else None,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if watch:
|
||||||
n_object.update(watch.extra_notification_token_values())
|
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.trace(f"Main rendered notification placeholders (diff_added etc) calculated in {time.time()-now:.3f}s")
|
||||||
|
|
Ładowanie…
Reference in New Issue