fix(calls): send native push for incoming calls + replay on reconnect

Calls only notified over the chat WebSocket (CHAT.pushToUser), so a CLOSED app
(no live socket) never rang — unlike messages, which also call PUSH.sendToUser.
Add PUSH.sendToUser for both DM (startDmCall -> callee) and group (startGroupCall
-> other members) so APNs/FCM/WebPush alerts a closed device.

To make the alert actionable, add CALLS.replayActiveCalls(userId, ws), invoked
from the chat-hello handler: when a socket (re)connects, re-send any dm-call /
group-call the user is currently being rung into (the original events fire once at
call start and are missed by an app that was closed). Opening the app from the push
then re-surfaces the invite so they can answer within the ring window.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-27 22:13:52 +05:30
parent 1920258fd6
commit a0b3936799
2 changed files with 36 additions and 1 deletions
+3
View File
@@ -92,6 +92,9 @@ async function handle(ws, m, req) {
CHAT.register(u.id, ws);
ws.send(JSON.stringify({ type: 'chat-ready' }));
CHAT.broadcastPresence(u.id); // tell contacts this user just came online
// Re-ring any call this user is currently being called into (missed while their app was closed) —
// makes the call push actionable: opening the app resurfaces the invite so they can answer.
try { require('./calls').replayActiveCalls(u.id, ws); } catch (_) {}
break;
}
// Recipient's client acknowledges a DM was delivered → mark it + tell the sender.