Parental controls: approvals lift bedtime, bedtime follows the child's clock, urgent push + banner + reminders for requests, reward cap raised to 60
build-container / build (push) Successful in 4m3s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 5.5 committed 2026-10-29 08:29:47 -04:00
1 parent d0e4e82e0a
commit 0a33119807
11 files changed
+59 -19

No files matched your search

+6 -2
View File
@@ -48,7 +48,7 @@ async function send(dir, st, uid, payload) {
keys(); const { ref, ...wire } = payload;
let changed = false;
await Promise.all(st.subs.map(async s => {
try { await webpush.sendNotification(s.sub, JSON.stringify(wire), { TTL: 3600 }); stats.sent++; stats.lastOk = Date.now(); }
try { await webpush.sendNotification(s.sub, JSON.stringify(wire), payload.urgent ? { TTL: 900, urgency: 'high' } : { TTL: 3600 }); stats.sent++; stats.lastOk = Date.now(); }
catch (e) {
if (e.statusCode === 404 || e.statusCode === 410) { s.dead = true; changed = true; stats.expired++; }
else { stats.failed++; stats.lastErr = String(e.statusCode || e.message).slice(0, 120); stats.lastErrAt = Date.now(); console.warn('[push] send failed:', e.statusCode || e.message); }
@@ -191,5 +191,9 @@ async function handle(req, res) {
json(res, 404, { error: 'Not found' });
}
/** A notification for one person's devices (a chat message, say), unless they turned that kind off. */
/** Time-sensitive (a child asking for time, a parent's answer): goes to every device at once, ignores the chat on/off switch and quiet hours, stays on screen until seen, and is kept in Notifications too. */
async function notifyUrgent(uid, payload) { const dir = users.dirOf(uid), st = load(dir); if (!st.subs.length) return 0; await send(dir, st, null, { ...payload, urgent: true }); return st.subs.length; }
/** Remember a person's time zone (the app reports it), so bedtime and reminders follow their own clock. */
function setTz(uid, tz) { if (!tz || !validTz(tz)) return; const dir = users.dirOf(uid), st = load(dir); if (st.tz === tz) return; st.tz = tz; try { save(dir, st); } catch {} }
async function notify(uid, payload) { const dir = users.dirOf(uid), st = load(dir); if (!st.subs.length || st.chat === false) return; await send(dir, st, null, payload); }
module.exports = { handle, start, tick, localNow, notify, health };
module.exports = { handle, start, tick, localNow, notify, notifyUrgent, setTz, health };