From d773f2c765b5bfc8c85dc6a1a99bcc4893250e62 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 30 Nov 2020 10:51:23 +0300 Subject: [PATCH] Handle call updates only from the correct session. --- Telegram/SourceFiles/calls/calls_instance.cpp | 17 ++++++++++++----- Telegram/SourceFiles/calls/calls_instance.h | 5 +++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/calls/calls_instance.cpp b/Telegram/SourceFiles/calls/calls_instance.cpp index 15d9f53f6a..672d36e53c 100644 --- a/Telegram/SourceFiles/calls/calls_instance.cpp +++ b/Telegram/SourceFiles/calls/calls_instance.cpp @@ -301,7 +301,7 @@ void Instance::handleUpdate( update.match([&](const MTPDupdatePhoneCall &data) { handleCallUpdate(session, data.vphone_call()); }, [&](const MTPDupdatePhoneCallSignalingData &data) { - handleSignalingData(data); + handleSignalingData(session, data); }, [&](const MTPDupdateGroupCall &data) { handleGroupCallUpdate(session, data.vcall()); }, [&](const MTPDupdateGroupCallParticipants &data) { @@ -379,7 +379,9 @@ void Instance::handleCallUpdate( createCall(user, Call::Type::Incoming, phoneCall.is_video()); _currentCall->handleUpdate(call); } - } else if (!_currentCall || !_currentCall->handleUpdate(call)) { + } else if (!_currentCall + || (&_currentCall->user()->session() != session) + || !_currentCall->handleUpdate(call)) { DEBUG_LOG(("API Warning: unexpected phone call update %1").arg(call.type())); } } @@ -393,7 +395,8 @@ void Instance::handleGroupCallUpdate( if (const auto existing = session->data().groupCall(callId)) { existing->applyUpdate(call); } - if (_currentGroupCall) { + if (_currentGroupCall + && (&_currentGroupCall->channel()->session() == session)) { _currentGroupCall->handleUpdate(call); } } @@ -407,14 +410,18 @@ void Instance::handleGroupCallUpdate( if (const auto existing = session->data().groupCall(callId)) { existing->applyUpdate(update); } - if (_currentGroupCall) { + if (_currentGroupCall + && (&_currentGroupCall->channel()->session() == session)) { _currentGroupCall->handleUpdate(update); } } void Instance::handleSignalingData( + not_null session, const MTPDupdatePhoneCallSignalingData &data) { - if (!_currentCall || !_currentCall->handleSignalingData(data)) { + if (!_currentCall + || (&_currentCall->user()->session() != session) + || !_currentCall->handleSignalingData(data)) { DEBUG_LOG(("API Warning: unexpected call signaling data %1" ).arg(data.vphone_call_id().v)); } diff --git a/Telegram/SourceFiles/calls/calls_instance.h b/Telegram/SourceFiles/calls/calls_instance.h index 3705bbcc58..6877e1422a 100644 --- a/Telegram/SourceFiles/calls/calls_instance.h +++ b/Telegram/SourceFiles/calls/calls_instance.h @@ -92,8 +92,6 @@ private: void requestPermissionsOrFail(Fn onSuccess); void requestPermissionOrFail(Platform::PermissionType type, Fn onSuccess); - void handleSignalingData(const MTPDupdatePhoneCallSignalingData &data); - void refreshDhConfig(); void refreshServerConfig(not_null session); bytes::const_span updateDhConfig(const MTPmessages_DhConfig &data); @@ -104,6 +102,9 @@ private: void handleCallUpdate( not_null session, const MTPPhoneCall &call); + void handleSignalingData( + not_null session, + const MTPDupdatePhoneCallSignalingData &data); void handleGroupCallUpdate( not_null session, const MTPGroupCall &call);