aboutsummaryrefslogtreecommitdiffstats
path: root/nwcpush
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-04 09:25:23 -0700
committerAdam Soltys <[email protected]>2026-10-04 09:25:23 -0700
commitb0fdec8eef365805f7a3a57bd5ec5563472785f9 (patch)
tree98778a90916e6eaeede205824765e8c87c0a7e67 /nwcpush
parent630b14ef0483ff49a17993a16556047dff80305c (diff)
downloadcoinosv3-b0fdec8eef365805f7a3a57bd5ec5563472785f9.tar.gz
coinosv3-b0fdec8eef365805f7a3a57bd5ec5563472785f9.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_011bvzKaZosXGHkigcGcSzAR
Diffstat (limited to 'nwcpush')
-rw-r--r--nwcpush/server.js11
1 files 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) {