aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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) {