mirror of
https://github.com/FAUSheppy/atlantis-event-dispatcher
synced 2025-12-06 06:21:36 +01:00
Compare commits
6 Commits
6e2e5e73da
...
7fa965a92c
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fa965a92c | |||
| e416149d35 | |||
| 181b3dae14 | |||
| c10bdf1fb7 | |||
| 6783426e5f | |||
| bc837169ff |
@@ -169,6 +169,23 @@ def webhooks():
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return ("", 204)
|
return ("", 204)
|
||||||
|
|
||||||
|
@app.route('/downtime', methods=["DELETE","POST"])
|
||||||
|
def downtime():
|
||||||
|
|
||||||
|
# check static access token #
|
||||||
|
token = flask.request.args.get("token")
|
||||||
|
if token != app.config["SETTINGS_ACCESS_TOKEN"]:
|
||||||
|
return ("SETTINGS_ACCESS_TOKEN incorrect. Refusing to access downtime settings", 401)
|
||||||
|
|
||||||
|
if flask.request.method == "DELETE":
|
||||||
|
app.config["DOWNTIME"] = datetime.datetime.now()
|
||||||
|
elif flask.request.method == "POST":
|
||||||
|
minutes = int(flask.request.args.get("minutes") or 5)
|
||||||
|
app.config["DOWNTIME"] = datetime.datetime.now() + datetime.timedelta(minutes=minutes)
|
||||||
|
|
||||||
|
return ('', 204)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/settings', methods=["GET", "POST"])
|
@app.route('/settings', methods=["GET", "POST"])
|
||||||
def settings():
|
def settings():
|
||||||
|
|
||||||
@@ -340,6 +357,11 @@ def smart_send_to_clients(path=None):
|
|||||||
title = instructions.get("title")
|
title = instructions.get("title")
|
||||||
method = instructions.get("method")
|
method = instructions.get("method")
|
||||||
|
|
||||||
|
if app.config["DOWNTIME"] > datetime.datetime.now():
|
||||||
|
print("Ignoring because of Downtime:", title, message, users, file=sys.stderr)
|
||||||
|
print("Downtime until", app.config["DOWNTIME"].isoformat(), file=sys.stderr)
|
||||||
|
return ("Ignored because of Downtime", 200)
|
||||||
|
|
||||||
# authenticated by access token or webhook path #
|
# authenticated by access token or webhook path #
|
||||||
dispatch_acces_token = flask.request.args.get("dispatch-access-token") or ""
|
dispatch_acces_token = flask.request.args.get("dispatch-access-token") or ""
|
||||||
print(path)
|
print(path)
|
||||||
@@ -433,6 +455,8 @@ def create_app():
|
|||||||
|
|
||||||
print("Loaded subs:", substitution_config_file, app.config["SUBSTITUTIONS"], file=sys.stderr)
|
print("Loaded subs:", substitution_config_file, app.config["SUBSTITUTIONS"], file=sys.stderr)
|
||||||
|
|
||||||
|
# set small downtime #
|
||||||
|
app.config["DOWNTIME"] = datetime.datetime.now() + datetime.timedelta(minutes=1)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user