Implement tasks 40, 41, 42: web push, notification bus, reminders engine
Task 40 — Web Push (VAPID): - Add web-push package + @types/web-push - pnpm vapid:generate script prints VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY, NEXT_PUBLIC_VAPID_PUBLIC_KEY - push_subscriptions schema + migration 0013 - _core/push.ts: sendPush() iterates subscriptions, prunes 404/410 stale entries - SW push/notificationclick event handlers added to generated sw.js template - PushOptIn client component on /settings (opt-in, disable, send test) Task 42 — Notification bus + ntfy adapter: - notifications table + notif_push/notif_inapp/notif_ntfy user columns (migration 0013) - _core/notify.ts: notify() fans out to push, in-app DB, and optional ntfy POST - NotificationBell server component in AppNav: unread badge, dropdown inbox, mark-read - NotifyChannelToggles client component in /settings Task 41 — Reminders engine: - fired_at + created_by added to reminders; default channel changed to 'auto' - _core/reminders.ts: scheduleReminder (upsert), cancelReminder, listReminders, tickReminders - tickReminders uses pg_try_advisory_xact_lock for horizontal-scale safety - src/instrumentation.ts starts reminder worker (30s tick) on Node.js boot - Notes actions use scheduleReminder/cancelReminder instead of raw SQL - Calendar createEvent: optional remindMinutesBefore, deleteEvent: cancelReminder - Calendar-shell: "Remind me 30 min before" checkbox on new event form Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
ec20f1bc87
commit
b6abe052c9
@@ -89,6 +89,38 @@ self.addEventListener("fetch", (e) => {
|
||||
}
|
||||
});
|
||||
|
||||
// --- push notifications ---
|
||||
|
||||
self.addEventListener("push", (e) => {
|
||||
if (!e.data) return;
|
||||
const data = e.data.json();
|
||||
e.waitUntil(
|
||||
self.registration.showNotification(data.title || "famapp", {
|
||||
body: data.body || "",
|
||||
data: { url: data.url || "/" },
|
||||
icon: "/icon-192.png",
|
||||
badge: "/icon-192.png",
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("notificationclick", (e) => {
|
||||
e.notification.close();
|
||||
const url = e.notification.data?.url || "/";
|
||||
e.waitUntil(
|
||||
self.clients
|
||||
.matchAll({ type: "window", includeUncontrolled: true })
|
||||
.then((cs) => {
|
||||
const match = cs.find((c) => c.url.includes(self.location.origin));
|
||||
if (match) {
|
||||
match.focus();
|
||||
return match.navigate(url);
|
||||
}
|
||||
return self.clients.openWindow(url);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
// --- strategy helpers ---
|
||||
|
||||
async function staleWhileRevalidate(request, cacheName) {
|
||||
|
||||
Reference in New Issue
Block a user