From 34deac51e32440284e5948d94a02ad131e1f430e Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 21 Apr 2020 22:27:17 +0400 Subject: [PATCH] Drop the call session if receivedCall returns an error [skip ci] --- .../TelegramCore/Sources/CallSessionManager.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/submodules/TelegramCore/Sources/CallSessionManager.swift b/submodules/TelegramCore/Sources/CallSessionManager.swift index 301a47a4ee..3149687642 100644 --- a/submodules/TelegramCore/Sources/CallSessionManager.swift +++ b/submodules/TelegramCore/Sources/CallSessionManager.swift @@ -351,7 +351,15 @@ private final class CallSessionManagerContext { let internalId = CallSessionInternalId() let context = CallSessionContext(peerId: peerId, isOutgoing: false, state: .ringing(id: stableId, accessHash: accessHash, gAHash: gAHash, b: b)) self.contexts[internalId] = context - context.acknowledgeIncomingCallDisposable.set(self.network.request(Api.functions.phone.receivedCall(peer: .inputPhoneCall(id: stableId, accessHash: accessHash))).start()) + let queue = self.queue + context.acknowledgeIncomingCallDisposable.set(self.network.request(Api.functions.phone.receivedCall(peer: .inputPhoneCall(id: stableId, accessHash: accessHash))).start(error: { [weak self] _ in + queue.async { + guard let strongSelf = self else { + return + } + strongSelf.drop(internalId: internalId, reason: .disconnect, debugLog: .single(nil)) + } + })) self.contextIdByStableId[stableId] = internalId self.contextUpdated(internalId: internalId) self.ringingStatesUpdated()