diff options
| author | Adam Soltys <[email protected]> | 2026-08-14 01:19:44 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-14 01:19:44 -0700 |
| commit | 7a7b2c61fe8394844fa306debb84917454ade7b0 (patch) | |
| tree | 4d2505c52dc239b5379e43400ac7bf822773e7aa /nwcpush/server.js | |
| parent | 5b23470f5d9ec7ee7cc33c2b4b936ddd24fa17cc (diff) | |
| download | coinosv3-7a7b2c61fe8394844fa306debb84917454ade7b0.tar.gz coinosv3-7a7b2c61fe8394844fa306debb84917454ade7b0.zip | |
Settings grows a Notifications page — per-category switches the notifier honours server-side — and the status bar gets a real coinos badge instead of a black blob
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014tE4U5nEjGTQy8PwYqamfv
Diffstat (limited to 'nwcpush/server.js')
| -rw-r--r-- | nwcpush/server.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/nwcpush/server.js b/nwcpush/server.js index 6300732..7efebb1 100644 --- a/nwcpush/server.js +++ b/nwcpush/server.js @@ -150,6 +150,7 @@ function onNotifyEvent(ev) { } async function pushNotify(id, r, reason, extra) { + if (r.reasons && r.reasons[reason] === false) return; // opted out of this category const key = id + ':' + reason; const last = lastPush.get(key) || 0; if (Date.now() - last < (COOLDOWN[reason] || 10_000)) return; @@ -356,10 +357,16 @@ const server = Bun.serve({ if (body?.notify && sub_?.endpoint) { const hex = (a, cap) => [...new Set((a || []).filter((p) => /^[0-9a-f]{64}$/.test(p)))].slice(0, cap); const id = Bun.hash(sub_.endpoint).toString(36); + // per-category opt-outs; absent means everything on (older clients) + const reasons = {}; + for (const k of ['payment', 'dm', 'chat']) { + if (typeof body.notify.reasons?.[k] === 'boolean') reasons[k] = body.notify.reasons[k]; + } notifyRegs[id] = { sub: sub_, updated: Date.now(), ptags: hex(body.notify.ptags, 8), authors: hex(body.notify.authors, 64), + reasons, }; persist(); resubscribeNotify(); |
