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