Compare commits

...

5 Commits

Author SHA1 Message Date
f3903b3936 feat: minimal logging for debugging server & fix import
All checks were successful
ci / docker (push) Successful in 1m13s
2026-03-28 22:17:16 +01:00
39f795bbb6 feat: minimal logging for debugging 2026-03-28 22:12:29 +01:00
f468a789e3 fix: make polling interval configurable
All checks were successful
ci / docker (push) Successful in 1m15s
2026-03-11 15:40:04 +01:00
527fa97dc8 fix: prevent substitutions=none if yaml is empty 2026-03-11 15:17:34 +01:00
000b7d2f43 fix: handle bytes input from ldap better 2026-03-11 15:10:55 +01:00
2 changed files with 19 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ import requests
import re
import smtphelper
import json
import datetime
HTTP_NOT_FOUND = 404
@@ -174,6 +175,8 @@ if __name__ == "__main__":
smtp_pass = args.smtp_pass or os.environ.get("SMTP_PASS")
smtp_port = args.smtp_port or os.environ.get("SMTP_PORT")
polling_interval = int(os.environ.get("POLLING_INTERVAL_SECONDS") or 5)
first_run = True
while args.loop or first_run:
@@ -209,6 +212,8 @@ if __name__ == "__main__":
email_address = entry.get("email")
# send message #
print(f"Sending: {method} {hash(str(title))} @ {datetime.datetime.now()}",
file=sys.stderr)
if method == "signal":
pass
elif method == "ntfy":
@@ -228,7 +233,7 @@ if __name__ == "__main__":
# wait a moment #
if args.loop:
time.sleep(5)
time.sleep(polling_interval)
# handle non-loop runs #
first_run = False

View File

@@ -67,7 +67,7 @@ class UserSettings(db.Model):
"email_priority" : self.email_priority,
"ntfy_priority" : self.ntfy_priority,
}
class DispatchObject(db.Model):
@@ -352,7 +352,6 @@ def smart_send_to_clients(path=None):
if not dispatch_acces_token:
dispatch_acces_token = flask.request.headers.get("Dispatcher-Token") or ""
print(path)
if path:
webhook_path = db.session.query(WebHookPaths).filter(WebHookPaths.path==path).first()
if webhook_path:
@@ -387,6 +386,8 @@ def smart_send_to_clients(path=None):
def save_in_dispatch_queue(persons, title, message, method, link=""):
now_str = str(datetime.datetime.now())
print(f"Scheduling message to {abs(hash(str(persons)))} @ {now_str}", file=sys.stderr)
dispatch_secrets = []
for p in persons:
@@ -398,6 +399,15 @@ def save_in_dispatch_queue(persons, title, message, method, link=""):
dispatch_secret = secrets.token_urlsafe(32)
master_method = "any"
# handle bytes input #
def normalize(v):
return v.decode("utf-8") if isinstance(v, bytes) else v
p.username = normalize(p.username)
p.phone = normalize(p.phone)
p.email = normalize(p.email)
obj = DispatchObject(username=p.username,
phone=p.phone,
email=p.email,
@@ -440,7 +450,7 @@ def create_app():
app.config["SUBSTITUTIONS"] = {}
if os.path.isfile(substitution_config_file):
with open(substitution_config_file) as f:
app.config["SUBSTITUTIONS"] = yaml.safe_load(f)
app.config["SUBSTITUTIONS"] = yaml.safe_load(f) or {}
print("Loaded subs:", substitution_config_file, app.config["SUBSTITUTIONS"], file=sys.stderr)