feat: replace Web Push with ntfy for medication reminders

Single notification path via ntfy HTTP publish for reliable Android delivery;
remove VAPID, push subscriptions, and SW push handlers. PWA settings show
topic subscribe link; humor texts and deep-link actions unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Frank Schwenk
2026-07-06 10:42:58 +02:00
parent 24ac7f2f48
commit 1cada42370
17 changed files with 251 additions and 323 deletions
+14 -14
View File
@@ -2,7 +2,7 @@ import { api } from "./lib/api.js";
import { getToken, setToken, clearToken, isLoggedIn } from "./lib/auth.js";
import { setStreakBadge } from "./lib/badge.js";
import { enqueue, flushQueue } from "./lib/offlineQueue.js";
import { registerPwa, wirePwaInstall, subscribePush } from "./lib/pwa.js";
import { registerPwa, wirePwaInstall } from "./lib/pwa.js";
import { renderSlots, renderHeatmap, updateStats, showToast, showConfetti, showEasterEgg } from "./lib/ui.js";
const STATUS = { upcoming: "Noch nicht", pending: "Jetzt!", overdue: "Überfällig", snoozed: "Snoozed", taken: "Genommen", missed: "Verpasst" };
@@ -153,20 +153,20 @@ async function initApp() {
location.reload();
});
document.getElementById("enablePush").addEventListener("click", async () => {
const statusEl = document.getElementById("pushStatus");
try {
const perm = await Notification.requestPermission();
if (perm !== "granted") { statusEl.textContent = "Permission verweigert."; return; }
const { key } = await api.vapidKey();
if (!key) { statusEl.textContent = "VAPID keys nicht konfiguriert."; return; }
const sub = await subscribePush(key);
await api.pushSubscribe(sub);
statusEl.textContent = "Push aktiv! Du wirst dezent erinnert.";
} catch (e) {
statusEl.textContent = e.message || "Push-Setup fehlgeschlagen.";
try {
const notify = await api.notifyConfig();
const topicEl = document.getElementById("notifyTopic");
const linkEl = document.getElementById("notifySubscribeLink");
if (notify.configured && notify.subscribe_url) {
topicEl.textContent = `Topic: ${notify.topic}`;
linkEl.href = notify.subscribe_url;
} else {
topicEl.textContent = "ntfy nicht konfiguriert (NTFY_URL + NTFY_TOPIC in .env).";
linkEl.hidden = true;
}
});
} catch {
document.getElementById("notifyTopic").textContent = "Notify-Config konnte nicht geladen werden.";
}
await flushQueue((data) => api.log(data));
await refreshDashboard();