aboutsummaryrefslogtreecommitdiffstats
path: root/src/calls.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/calls.js')
-rw-r--r--src/calls.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/calls.js b/src/calls.js
index 827d605..66d6f16 100644
--- a/src/calls.js
+++ b/src/calls.js
@@ -64,7 +64,8 @@ export const candidateJson = (c) => JSON.stringify({ candidate: c.candidate, sdp
// send(peerPk, signed) wrap and publish to them (the app picks the relays)
// iceServers() → RTCIceServer[] (TURN from coinos, STUN at least)
// media(type, facing) → MediaStream: microphone, and camera for 'video'
-// mayRing(pk) whether this person may ring us (followed, or a conversation)
+// mayRing(pk) 'ring' (someone followed, or written to), 'quiet' (anyone else:
+// no ring, but the call is told of, as missed), or null (muted: nothing)
// changed() the call's state moved: draw it
// ended(record) a call is over: { id, peer, type, dir, reason, connected, seconds, at } for its log
// trickle() false for a signer that's slow or asks each time (a
@@ -247,7 +248,14 @@ export function createCalls(env) {
if (c.id !== id) { const s = await env.sign(callEvent(CALL.REJECT, from, id, 'busy')); env.send(from, s).catch(() => {}); }
return;
}
- if (!(await env.mayRing(from))) return;
+ const may = await env.mayRing(from);
+ if (!may) return;
+ if (may === 'quiet') {
+ // not someone who rings us: no ring, but not nothing either — it's
+ // logged as a call that didn't ring
+ try { if (env.ended) env.ended({ id, peer: from, type: tagOf(ev, 'call-type') === 'video' ? 'video' : 'voice', dir: 'in', reason: 'unrung', connected: false, seconds: 0, at: ev.created_at * 1000 }); } catch {}
+ return;
+ }
clearTimeout(endTimer);
const type = tagOf(ev, 'call-type') === 'video' ? 'video' : 'voice';
const n = call = { id, peer: from, type, dir: 'in', state: 'incoming', offer: ev.content, ice: [], at: Date.now(), offerAt: ev.created_at * 1000, muted: false, camOff: false, facing: 'user' };