From b0fdec8eef365805f7a3a57bd5ec5563472785f9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 4 Oct 2026 09:25:23 -0700 Subject: nwcpush: zaps, payments, DMs and mentions push high-urgency, kept a day Android holds 'normal' pushes while the phone dozes and drops them once the 1 h TTL runs out; a pocketed phone missed most zaps and mentions that the laptop showed. Reactions and community chat stay normal. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011bvzKaZosXGHkigcGcSzAR --- nwcpush/server.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nwcpush/server.js b/nwcpush/server.js index 4110f91..6d56f84 100644 --- a/nwcpush/server.js +++ b/nwcpush/server.js @@ -218,16 +218,23 @@ async function pushNotify(id, r, reason, extra) { if (Date.now() - last < (COOLDOWN[reason] || 10_000)) return; lastPush.set(key, Date.now()); const payload = JSON.stringify({ type: 'notify', reason, ...extra }); + // Android holds a 'normal' push while the phone dozes and batches it into + // the next maintenance window — and drops it once TTL runs out first. A + // phone in a pocket missed most zaps and mentions this way (a laptop never + // dozes, so it got them all). Money and people talking to you go 'high' + // and keep for a day; reactions and community chatter can wait. + const loud = ['payment', 'zap', 'dm', 'mention'].includes(reason); + const opts = loud ? { TTL: 86400, urgency: 'high' } : { TTL: 3600, urgency: 'normal' }; try { try { - await deliver(r.sub, payload, { TTL: 3600, urgency: 'normal' }); + await deliver(r.sub, payload, opts); } catch (e) { // A payload the push service won't take (413, or the library refusing // the size) must not cost the notification itself — send the bare nudge // and let the device show its generic message. if (!extra.wrap || (e.statusCode && e.statusCode !== 413)) throw e; log(`notify(dm): payload rejected (${e.statusCode || e.message}), retrying bare`); - await deliver(r.sub, JSON.stringify({ type: 'notify', reason }), { TTL: 3600, urgency: 'normal' }); + await deliver(r.sub, JSON.stringify({ type: 'notify', reason }), opts); } log(`notify(${reason}) -> device ${id}`); } catch (e) { -- cgit v1.2.3