Исправить маршрутизацию call push по sessionId

This commit is contained in:
AidarKC
2026-06-19 19:18:16 +04:00
parent 47574100f9
commit cc074a941f
7 changed files with 56 additions and 5 deletions
+10
View File
@@ -269,6 +269,13 @@ function savePendingCallPushAction(action, payload = {}) {
}
}
function isCallPushTargetForCurrentSession(payload = {}) {
const targetSessionId = String(payload?.targetSessionId || '').trim();
if (!targetSessionId) return true;
const currentSessionId = String(state?.session?.sessionId || '').trim();
return Boolean(currentSessionId) && currentSessionId === targetSessionId;
}
function loadPendingCallPushAction() {
try {
const raw = localStorage.getItem(CALL_PUSH_PENDING_ACTION_KEY);
@@ -322,6 +329,7 @@ async function processPendingCallPushActionIfPossible() {
if (!state.session.isAuthorized) return;
const pending = loadPendingCallPushAction();
if (!pending) return;
if (!isCallPushTargetForCurrentSession(pending.payload || {})) return;
clearPendingCallPushAction();
try {
await handleCallPushAction(pending.action, pending.payload || {});
@@ -827,6 +835,7 @@ async function init() {
const action = String(data.action || '').trim().toLowerCase();
const payload = data.payload || {};
if (action === 'accept' || action === 'decline') {
if (!isCallPushTargetForCurrentSession(payload)) return;
savePendingCallPushAction(action, payload);
void processPendingCallPushActionIfPossible();
}
@@ -835,6 +844,7 @@ async function init() {
if (data.type !== 'SHINE_WEB_PUSH_EVENT') return;
const payload = data.payload || {};
if (!isCallPushTargetForCurrentSession(payload)) return;
const kind = String(payload.kind || '').trim();
const now = Date.now();
try {