Ajoute le support d'un jeton d'accès pour les serveurs ntfy protégés
Certains serveurs ntfy auto-hébergés (ex: ntfy.arkel.fr) renvoient
403 Forbidden sans authentification. Un nouveau champ "Jeton d'accès"
(optionnel, type password) sur /settings permet de renseigner un token
qui sera envoyé comme "Authorization: Bearer ..." à chaque publication,
pour les rappels réels comme pour le bouton de test. La page /aide
documente le cas 403 et la marche à suivre.
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
This commit is contained in:
@ -156,11 +156,12 @@ DEFAULT_RAPPEL_FIN_H = 20
|
||||
|
||||
|
||||
def load_notif_config(user_id: str) -> dict:
|
||||
"""Return {"ntfy_topic", "ntfy_server", "rappel_debut_h", "rappel_fin_h", "token"}."""
|
||||
"""Return {ntfy_topic, ntfy_server, ntfy_token, rappel_debut_h, rappel_fin_h, token}."""
|
||||
f = _notif_file(user_id)
|
||||
if f.exists():
|
||||
cfg = json.loads(f.read_text())
|
||||
cfg.setdefault("ntfy_server", DEFAULT_NTFY_SERVER)
|
||||
cfg.setdefault("ntfy_token", "")
|
||||
cfg.setdefault("rappel_debut_h", DEFAULT_RAPPEL_DEBUT_H)
|
||||
cfg.setdefault("rappel_fin_h", DEFAULT_RAPPEL_FIN_H)
|
||||
if cfg.get("token"):
|
||||
@ -168,6 +169,7 @@ def load_notif_config(user_id: str) -> dict:
|
||||
else:
|
||||
cfg = {
|
||||
"ntfy_topic": None, "ntfy_server": DEFAULT_NTFY_SERVER,
|
||||
"ntfy_token": "",
|
||||
"rappel_debut_h": DEFAULT_RAPPEL_DEBUT_H, "rappel_fin_h": DEFAULT_RAPPEL_FIN_H,
|
||||
}
|
||||
cfg["token"] = secrets.token_hex(16)
|
||||
@ -179,10 +181,12 @@ def load_notif_config(user_id: str) -> dict:
|
||||
def save_notif_config(
|
||||
user_id: str, ntfy_topic: str, ntfy_server: str = "",
|
||||
rappel_debut_h: int = DEFAULT_RAPPEL_DEBUT_H, rappel_fin_h: int = DEFAULT_RAPPEL_FIN_H,
|
||||
ntfy_token: str = "",
|
||||
):
|
||||
cfg = load_notif_config(user_id)
|
||||
cfg["ntfy_topic"] = ntfy_topic.strip() or None
|
||||
cfg["ntfy_server"] = ntfy_server.strip().rstrip("/") or DEFAULT_NTFY_SERVER
|
||||
cfg["ntfy_token"] = ntfy_token.strip()
|
||||
cfg["rappel_debut_h"] = rappel_debut_h
|
||||
cfg["rappel_fin_h"] = rappel_fin_h
|
||||
_ensure_user_dirs(user_id)
|
||||
|
||||
Reference in New Issue
Block a user