From 029da7e0ceaecef91648a7bb0ebc7f084d55515b Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 21 Jun 2017 15:16:57 -0400 Subject: [PATCH] Hang up current call if we receive a call offer from the same user. // FREEBIE --- Signal/src/call/CallService.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index 63a644872..46a7897a9 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -462,7 +462,7 @@ protocol CallServiceObserver: class { let callerName = self.contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier()) - switch(untrustedIdentity!.verificationState) { + switch untrustedIdentity!.verificationState { case .verified: Logger.error("\(TAG) shouldn't have missed a call due to untrusted identity if the identity is verified") assertionFailure("shouldn't have missed a call due to untrusted identity if the identity is verified") @@ -492,6 +492,16 @@ protocol CallServiceObserver: class { handleLocalBusyCall(newCall, thread: thread) + if self.call?.remotePhoneNumber == newCall.remotePhoneNumber { + // If we're receiving a new call offer from the user we think we have a call with, terminate + // our current call to get back to a known good state. If they call back, we'll be ready. + // + // TODO: Auto-accept this incoming call if our current call was either a) outgoing or + // b) ever connected. There will be a bit of complexity around making sure that two + // parties that call each other at the same time end up connected. + terminateCall() + } + return }