From 56cad7ef0da868e7c7c2b3c902143acd611b4c48 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 18 Oct 2026 09:01:17 -0700 Subject: nwcpush: calls push only to an app that says it rings for them (reasons.call), not to an older one whose worker would show a call as chat. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013ZDf1cyCQLkfjftYhymZAg --- tools/nwcpush-call-test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/nwcpush-call-test.js b/tools/nwcpush-call-test.js index 9145744..99b366b 100644 --- a/tools/nwcpush-call-test.js +++ b/tools/nwcpush-call-test.js @@ -33,7 +33,7 @@ const relay = Bun.serve({ port: 0, hostname: '127.0.0.1', close(ws) { for (const s of ws.data.values()) subs.delete(s); }, } }); // the devices: what each was pushed -const got = { on: [], off: [] }; +const got = { on: [], off: [], old: [] }; const devices = Bun.serve({ port: 0, hostname: '127.0.0.1', fetch: async (req) => { got[new URL(req.url).pathname.slice(1)].push(await req.json()); return new Response('ok'); } }); const dir = mkdtempSync(tmpdir() + '/nwcpush-call-'); @@ -54,7 +54,8 @@ try { for (let i = 0; i < 40; i++) { try { if ((await fetch(N + '/health')).ok) break; } catch {} await sleep(150); } const reg = (path, reasons) => fetch(N + '/register', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ subscription: { endpoint: `http://127.0.0.1:${devices.port}/${path}`, unifiedpush: true }, notify: { ptags: [ME], reasons } }) }); - check('a device registers for its pubkey', (await reg('on', {})).ok); + check('a device registers for its pubkey', (await reg('on', { call: true })).ok); + check('...an older app, saying nothing of calls', (await reg('old', {})).ok); check('...another with calls turned off', (await reg('off', { call: false })).ok); await sleep(1000); // the notifier resubscribes @@ -65,6 +66,7 @@ try { const push = got.on.find((p) => p.reason === 'call'); check('the device is woken: a call, naming the wrap', !!push && push.type === 'notify' && push.wrapId === offer.id, JSON.stringify(got.on)); check('...not the one that turned calls off', !got.off.some((p) => p.reason === 'call')); + check('...nor an older app (its worker would call it chat)', !got.old.some((p) => p.reason === 'call')); const fetched = await (await fetch(N + '/wrap/' + offer.id)).json(); check('the wrap can be fetched from the notifier, as sent', fetched.id === offer.id && fetched.content === offer.content); check('...from any page (CORS)', (await fetch(N + '/wrap/' + offer.id)).headers.get('access-control-allow-origin') === '*'); -- cgit v1.2.3