Ajoute un bouton de test de la notification ntfy depuis les réglages

Permet de vérifier en un clic que le serveur et le topic ntfy
renseignés fonctionnent, avant d'attendre un vrai rappel. Le bouton
envoie une notification de test via la même chaîne que les rappels
réels (donc tracée dans /logs), et affiche le résultat inline.
La fonction send_ntfy retourne désormais un booléen de succès pour
permettre ce retour utilisateur.

💘 Generated with Crush

Assisted-by: Crush:glm-5.2
This commit is contained in:
Jacquin Antoine
2026-07-19 23:57:48 +02:00
parent f82f443ec7
commit 2ee317a46e
4 changed files with 109 additions and 2 deletions

View File

@ -11,7 +11,7 @@ logger = logging.getLogger("pointeuse.notifications")
CHECK_INTERVAL_SECONDS = 300
def send_ntfy(server: str, topic: str, message: str, title: str, user_id: str | None = None):
def send_ntfy(server: str, topic: str, message: str, title: str, user_id: str | None = None) -> bool:
req = urllib.request.Request(
f"{server}/{topic}",
data=message.encode("utf-8"),
@ -23,11 +23,13 @@ def send_ntfy(server: str, topic: str, message: str, title: str, user_id: str |
logger.info("notif ntfy envoyée: server=%r topic=%r title=%r", server, topic, title)
if user_id:
append_log(user_id, "notif", "envoyée", f"{title}{message}")
return True
except Exception:
logger.exception("échec de l'envoi ntfy: server=%r topic=%r title=%r", server, topic, title)
if user_id:
append_log(user_id, "notif", "échec", f"{title}{message}")
# best-effort: a missed reminder isn't worth crashing the loop
return False
def _todays_pointage(user_id: str, today: datetime) -> dict: