Add ntfy push notifications with action buttons for meal reminders
CI / test-and-package (push) Successful in 37s

- ntfy.py: send_meal_reminder() with Home/Out HTTP action buttons, test helper
- models.py: new columns ntfy_url, ntfy_token, callback_token on users table
- meals.py: /api/ntfy-callback (public, token-authenticated), /ntfy-settings, /ntfy-test
- app.py: flask send-reminders CLI command (cron-schedulable)
- Dashboard: ntfy config form in Account Settings
- i18n: translations for all ntfy strings (en/fr/de)
- Dockerfile: include ntfy.py in COPY
- tests: 15 new tests covering callback, settings, and auth
- docs: updated AGENTS.md and doc/index.md
This commit is contained in:
agentbox
2026-08-01 06:17:26 +00:00
parent 7bf00ee2e3
commit 3681f9dfce
10 changed files with 650 additions and 4 deletions
+37 -1
View File
@@ -1,13 +1,16 @@
"""Meal Tracker — Flask application entry point."""
import os
from datetime import date
import click
from flask import Flask
from models import init_db
from models import init_db, get_users_with_ntfy, get_all_households
from auth import auth_bp
from meals import meals_bp
from i18n import init_i18n
from ntfy import send_meal_reminder
def create_app() -> Flask:
@@ -22,6 +25,39 @@ def create_app() -> Flask:
init_i18n(app)
# ── CLI commands ──
@app.cli.command("send-reminders")
@click.option("--date", default=None, help="Date to send reminders for (YYYY-MM-DD, default: today)")
@click.option("--meal", default="both", type=click.Choice(["lunch", "dinner", "both"]),
help="Which meal to send reminders for (default: both)")
@click.option("--base-url", default=None, help="Base URL of the app (default: $APP_BASE_URL or http://localhost:5000)")
def send_reminders_command(date, meal, base_url):
"""Send ntfy meal reminders to all users who have ntfy configured."""
target_date = date and __import__("datetime").datetime.strptime(date, "%Y-%m-%d").date() or date.today()
app_base_url = base_url or os.environ.get("APP_BASE_URL", "http://localhost:5000")
meal_types = ["lunch", "dinner"] if meal == "both" else [meal]
total_sent = 0
for household in get_all_households():
for user in get_users_with_ntfy(household["id"]):
for mt in meal_types:
ok = send_meal_reminder(
ntfy_url=user["ntfy_url"],
ntfy_token=user["ntfy_token"],
callback_token=user["callback_token"],
meal_type=mt,
for_date=target_date,
app_base_url=app_base_url,
)
if ok:
total_sent += 1
click.echo(f"{user['username']} ({mt})")
else:
click.echo(f"{user['username']} ({mt}) — failed")
click.echo(f"\nSent {total_sent} reminder(s) for {target_date.isoformat()}.")
return app