Compare commits

...

3 Commits

Author SHA1 Message Date
f2137e7e4c fix: deal with empty body or title
Some checks failed
ci / docker (push) Failing after 15s
2025-01-05 15:30:12 +01:00
c577802e63 fi: limit title and body length 2025-01-05 15:21:28 +01:00
2a74d9816f fix: honor 429 response 2025-01-05 15:19:53 +01:00

View File

@@ -57,6 +57,12 @@ def ntfy_api_get_topic(ntfy_api_server, ntfy_api_token, username):
def ntfy_send(dispatch_uuid, user_topic, title, message, ntfy_push_target, ntfy_user, ntfy_pass):
'''Send message via NTFY topic'''
# limit message length and title #
title = title or ""
message = message or ""
message = message[:1024]
title = title[:512]
if not user_topic:
report_failed_dispatch(dispatch_uuid, "No user topic")
return
@@ -78,6 +84,9 @@ def ntfy_send(dispatch_uuid, user_topic, title, message, ntfy_push_target, ntfy_
# send #
r = requests.post(ntfy_push_target, auth=(ntfy_user, ntfy_pass), json=payload)
print(r.status_code, r.text, payload)
if r.status_code == 429: # rate-limit
time.sleep(60)
r.raise_for_status()
# talk to dispatch #