diff options
Diffstat (limited to 'src/sw-nwc.js')
| -rw-r--r-- | src/sw-nwc.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/sw-nwc.js b/src/sw-nwc.js index b6af6b8..f9d383e 100644 --- a/src/sw-nwc.js +++ b/src/sw-nwc.js @@ -35,6 +35,17 @@ self.addEventListener('push', (e) => { if (r.ok) ring = await classifyCall(await r.json(), await allInboxes()); } catch (err) { console.warn('[sw-call] could not open:', err && err.message); } if (!ring) return; + if (ring.quiet) { + // no ring for them; a note for the app, which lists it as a missed call + try { + const cache = await caches.open(CALL_CACHE); + const had = await cache.match('/__quiet-calls'); + const list = had ? await had.json() : []; + list.push(ring.offer); + await cache.put('/__quiet-calls', new Response(JSON.stringify(list.slice(-20)), { headers: { 'content-type': 'application/json' } })); + } catch (_) {} + return; + } try { const cache = await caches.open(CALL_CACHE); await cache.put('/__pending-call', new Response(JSON.stringify({ offer: ring.offer, at: Date.now() }), { headers: { 'content-type': 'application/json' } })); |
