Make sure that a webhook function never returns a null response

This commit is contained in:
Fabio Manganiello 2022-09-04 00:52:41 +02:00
parent 1ea53a6f50
commit a90aa2cb2e

View file

@ -60,7 +60,7 @@ def hook_route(hook_name):
try: try:
send_message(event) send_message(event)
rs = make_response(json.dumps({'status': 'ok', **event_args})) rs = default_rs = make_response(json.dumps({'status': 'ok', **event_args}))
headers = {} headers = {}
status_code = 200 status_code = 200
@ -78,6 +78,10 @@ def hook_route(hook_name):
status_code = rs.get('___code___', status_code) status_code = rs.get('___code___', status_code)
rs = rs['___data___'] rs = rs['___data___']
if rs is None:
rs = default_rs
headers = {'Content-Type': 'application/json'}
rs = make_response(rs) rs = make_response(rs)
else: else:
headers = {'Content-Type': 'application/json'} headers = {'Content-Type': 'application/json'}