aboutsummaryrefslogtreecommitdiffstats
path: root/src/dm-inbox.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/dm-inbox.js')
-rw-r--r--src/dm-inbox.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/dm-inbox.js b/src/dm-inbox.js
index 1a026c1..58fc72d 100644
--- a/src/dm-inbox.js
+++ b/src/dm-inbox.js
@@ -122,7 +122,8 @@ export function shouldNotifyDm(verdict) {
// it's for, and worth ringing only as a fresh offer from someone this
// account follows or talks to, and hasn't muted. Returns { offer, name,
// type } to ring with, or null for anything else (a candidate, a stranger,
-// a stale one, a wrap we hold no key for).
+// a stale one, a wrap we hold no key for); `quiet` for a caller who
+// may not ring us (not followed, not written to).
export async function classifyCall(wrap, inboxes, nowS = Math.floor(Date.now() / 1000)) {
for (const rec of inboxes) {
if (!rec || !rec.sk) continue;
@@ -133,9 +134,11 @@ export async function classifyCall(wrap, inboxes, nowS = Math.floor(Date.now() /
const from = ev.pubkey;
if (ev.kind !== CALL.OFFER || from === rec.pubkey || nowS - ev.created_at > RING_S) return null;
if ((rec.muted || []).includes(from)) return null;
- if (!(rec.follows || []).includes(from) && !(rec.known || []).includes(from)) return null;
const type = (ev.tags.find((x) => x[0] === 'call-type') || [])[1] === 'video' ? 'video' : 'voice';
- return { offer: ev, name: (rec.names || {})[from] || null, type };
+ // someone not followed nor written to doesn't ring — `quiet`: the app
+ // lists it as a call that didn't ring, next time it opens
+ const quiet = !(rec.follows || []).includes(from) && !(rec.rings || rec.known || []).includes(from);
+ return { offer: ev, name: (rec.names || {})[from] || null, type, quiet };
}
return null;
}