mirror of
https://github.com/FAUSheppy/atlantis-event-dispatcher
synced 2025-12-06 06:21:36 +01:00
feat: support 'message' & 'link' fields
This commit is contained in:
@@ -84,6 +84,7 @@ class DispatchObject(db.Model):
|
|||||||
title = Column(String)
|
title = Column(String)
|
||||||
message = Column(String, primary_key=True)
|
message = Column(String, primary_key=True)
|
||||||
method = Column(String)
|
method = Column(String)
|
||||||
|
link = Column(String)
|
||||||
|
|
||||||
dispatch_secret = Column(String)
|
dispatch_secret = Column(String)
|
||||||
dispatch_error = Column(String)
|
dispatch_error = Column(String)
|
||||||
@@ -98,6 +99,7 @@ class DispatchObject(db.Model):
|
|||||||
"email" : self.email,
|
"email" : self.email,
|
||||||
"title" : _apply_substitution(self.title),
|
"title" : _apply_substitution(self.title),
|
||||||
"message" : _apply_substitution(self.message),
|
"message" : _apply_substitution(self.message),
|
||||||
|
"link" : self.link,
|
||||||
"uuid" : self.dispatch_secret,
|
"uuid" : self.dispatch_secret,
|
||||||
"method" : self.method,
|
"method" : self.method,
|
||||||
"error" : self.dispatch_error,
|
"error" : self.dispatch_error,
|
||||||
@@ -378,9 +380,10 @@ def smart_send_to_clients(path=None):
|
|||||||
instructions = flask.request.json
|
instructions = flask.request.json
|
||||||
users = instructions.get("users")
|
users = instructions.get("users")
|
||||||
groups = instructions.get("groups")
|
groups = instructions.get("groups")
|
||||||
message = instructions.get("msg")
|
message = instructions.get("msg") or instructions.get("message")
|
||||||
title = instructions.get("title")
|
title = instructions.get("title")
|
||||||
method = instructions.get("method")
|
method = instructions.get("method")
|
||||||
|
link = instructions.get("link")
|
||||||
|
|
||||||
if app.config["DOWNTIME"] > datetime.datetime.now():
|
if app.config["DOWNTIME"] > datetime.datetime.now():
|
||||||
print("Ignoring because of Downtime:", title, message, users, file=sys.stderr)
|
print("Ignoring because of Downtime:", title, message, users, file=sys.stderr)
|
||||||
@@ -421,7 +424,7 @@ def smart_send_to_clients(path=None):
|
|||||||
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, title, message, method)
|
dispatch_secrets = save_in_dispatch_queue(persons, title, message, method, link)
|
||||||
return flask.jsonify(dispatch_secrets)
|
return flask.jsonify(dispatch_secrets)
|
||||||
|
|
||||||
|
|
||||||
@@ -445,6 +448,7 @@ def save_in_dispatch_queue(persons, title, message, method):
|
|||||||
timestamp=datetime.datetime.now().timestamp(),
|
timestamp=datetime.datetime.now().timestamp(),
|
||||||
dispatch_secret=dispatch_secret,
|
dispatch_secret=dispatch_secret,
|
||||||
title=title,
|
title=title,
|
||||||
|
link=link,
|
||||||
message=message)
|
message=message)
|
||||||
|
|
||||||
db.session.merge(obj)
|
db.session.merge(obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user