mirror of
https://github.com/FAUSheppy/atlantis-event-dispatcher
synced 2025-12-06 06:21:36 +01:00
fix: message title
This commit is contained in:
@@ -46,7 +46,7 @@ def ntfy_api_get_topic(ntfy_api_server, ntfy_api_token, username):
|
||||
print(r.text)
|
||||
return r.json().get("topic")
|
||||
|
||||
def ntfy_send(dispatch_uuid, user_topic, message, ntfy_push_target, ntfy_user, ntfy_pass):
|
||||
def ntfy_send(dispatch_uuid, user_topic, title, message, ntfy_push_target, ntfy_user, ntfy_pass):
|
||||
'''Send message via NTFY topic'''
|
||||
|
||||
if not user_topic:
|
||||
@@ -57,13 +57,13 @@ def ntfy_send(dispatch_uuid, user_topic, message, ntfy_push_target, ntfy_user, n
|
||||
|
||||
# build message #
|
||||
payload = {
|
||||
"topic" : user_topic or "test", #TODO fix topic
|
||||
"topic" : user_topic,
|
||||
"message" : message,
|
||||
"title" : "Atlantis Notify",
|
||||
"title" : title or "Atlantis Notify",
|
||||
#"tags" : [],
|
||||
#"priority" : 4,
|
||||
"priority" : 4,
|
||||
#"attach" : None,
|
||||
#"click" : None,
|
||||
"click" : "https://vid.pr0gramm.com/2022/11/06/ed66c8c5a9cd1a3b.mp4",
|
||||
#"actions" : []
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ if __name__ == "__main__":
|
||||
smtp_pass = args.smtp_pass or os.environ.get("SMTP_PASS")
|
||||
|
||||
# request dispatches #
|
||||
response = requests.get(args.dispatch_server + "/get-dispatch?method=all", auth=AUTH)
|
||||
response = requests.get(args.dispatch_server + "/get-dispatch?method=all&timeout=0", auth=AUTH)
|
||||
|
||||
# check status #
|
||||
if response.status_code == HTTP_NOT_FOUND:
|
||||
@@ -165,6 +165,7 @@ if __name__ == "__main__":
|
||||
dispatch_uuid = entry["uuid"]
|
||||
method = entry["method"]
|
||||
message = entry["message"]
|
||||
title = entry.get("title")
|
||||
|
||||
# method dependent fields #
|
||||
phone = entry.get("phone")
|
||||
@@ -175,7 +176,8 @@ if __name__ == "__main__":
|
||||
pass
|
||||
elif method == "ntfy":
|
||||
user_topic = ntfy_api_get_topic(ntfy_api_server, ntfy_api_token, user)
|
||||
ntfy_send(dispatch_uuid, user_topic, message, ntfy_push_target, ntfy_user, ntfy_pass)
|
||||
ntfy_send(dispatch_uuid, user_topic, title, message,
|
||||
ntfy_push_target, ntfy_user, ntfy_pass)
|
||||
elif method == "email":
|
||||
email_send(dispatch_uuid, email_address, message, smtp_target, smtp_user, smtp_pass)
|
||||
elif method == "debug":
|
||||
|
||||
@@ -192,6 +192,7 @@ def smart_send_to_clients():
|
||||
users = instructions.get("users")
|
||||
groups = instructions.get("groups")
|
||||
message = instructions.get("msg")
|
||||
title = instructions.get("title")
|
||||
method = instructions.get("method")
|
||||
|
||||
# allow single use string instead of array #
|
||||
@@ -212,11 +213,11 @@ def smart_send_to_clients():
|
||||
else:
|
||||
persons = ldaptools.select_targets(users, groups, app.config["LDAP_ARGS"])
|
||||
|
||||
dispatch_secrets = save_in_dispatch_queue(persons, message, method)
|
||||
dispatch_secrets = save_in_dispatch_queue(persons, title, message, method)
|
||||
return flask.jsonify(dispatch_secrets)
|
||||
|
||||
|
||||
def save_in_dispatch_queue(persons, message, method):
|
||||
def save_in_dispatch_queue(persons, title, message, method):
|
||||
|
||||
|
||||
dispatch_secrets = []
|
||||
@@ -237,6 +238,7 @@ def save_in_dispatch_queue(persons, message, method):
|
||||
method=method or master_method,
|
||||
timestamp=datetime.datetime.now().timestamp(),
|
||||
dispatch_secret=dispatch_secret,
|
||||
title=title,
|
||||
message=message)
|
||||
|
||||
db.session.merge(obj)
|
||||
|
||||
Reference in New Issue
Block a user