Compare commits

..

6 Commits

Author SHA1 Message Date
7fa965a92c fix: change output to stderr
Some checks failed
ci / docker (push) Failing after 7s
2024-11-15 00:01:57 +01:00
e416149d35 fix: output users 2024-11-14 23:56:53 +01:00
181b3dae14 fix: add return view to endpoint 2024-11-14 23:54:39 +01:00
c10bdf1fb7 fix: output downtime after reading args 2024-11-14 23:53:24 +01:00
6783426e5f fix: add minutes default and cast 2024-11-14 23:50:15 +01:00
bc837169ff feat: implement downtime setting 2024-11-14 23:29:09 +01:00

View File

@@ -169,6 +169,23 @@ def webhooks():
db.session.commit()
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"])
def settings():
@@ -340,6 +357,11 @@ def smart_send_to_clients(path=None):
title = instructions.get("title")
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 #
dispatch_acces_token = flask.request.args.get("dispatch-access-token") or ""
print(path)
@@ -433,6 +455,8 @@ def create_app():
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__":