Merge branch 'mkirk/fix-missing-declined-call-record'
This commit is contained in:
commit
7d2684cafd
@ -597,7 +597,7 @@ class NotificationActionHandler {
|
||||
throw NotificationError.failDebug("unable to build localCallId. localCallIdString: \(localCallIdString)")
|
||||
}
|
||||
|
||||
callUIAdapter.declineCall(localId: localCallId)
|
||||
callUIAdapter.localHangupCall(localId: localCallId)
|
||||
return Promise.value(())
|
||||
}
|
||||
|
||||
|
||||
@ -948,7 +948,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
|
||||
@objc func didPressDeclineCall(sender: UIButton) {
|
||||
Logger.info("")
|
||||
|
||||
callUIAdapter.declineCall(call)
|
||||
callUIAdapter.localHangupCall(call)
|
||||
|
||||
dismissIfPossible(shouldDelay: false)
|
||||
}
|
||||
|
||||
@ -1211,61 +1211,6 @@ private class SignalCallData: NSObject {
|
||||
peerConnectionClient.setLocalVideoEnabled(enabled: shouldHaveLocalVideoTrack())
|
||||
}
|
||||
|
||||
/**
|
||||
* Local user chose to decline the call vs. answering it.
|
||||
*
|
||||
* The call is referred to by call `localId`, which is included in Notification actions.
|
||||
*
|
||||
* Incoming call only.
|
||||
*/
|
||||
public func handleDeclineCall(localId: UUID) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
guard let call = self.call else {
|
||||
// This should never happen; return to a known good state.
|
||||
owsFailDebug("call was unexpectedly nil")
|
||||
OWSProdError(OWSAnalyticsEvents.callServiceCallMissing(), file: #file, function: #function, line: #line)
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description: "call was unexpectedly nil"))
|
||||
return
|
||||
}
|
||||
|
||||
guard call.localId == localId else {
|
||||
// This should never happen; return to a known good state.
|
||||
owsFailDebug("callLocalId:\(localId) doesn't match current calls: \(call.localId)")
|
||||
OWSProdError(OWSAnalyticsEvents.callServiceCallIdMismatch(), file: #file, function: #function, line: #line)
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description: "callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
|
||||
return
|
||||
}
|
||||
|
||||
self.handleDeclineCall(call)
|
||||
}
|
||||
|
||||
/**
|
||||
* Local user chose to decline the call vs. answering it.
|
||||
*
|
||||
* Incoming call only.
|
||||
*/
|
||||
public func handleDeclineCall(_ call: SignalCall) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
Logger.info("\(call.identifiersForLogs).")
|
||||
|
||||
if let callRecord = call.callRecord {
|
||||
owsFailDebug("Not expecting callrecord to already be set")
|
||||
callRecord.updateCallType(.incomingDeclined)
|
||||
} else {
|
||||
// MJK TODO remove this timestamp param
|
||||
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(), callType: .incomingDeclined, in: call.thread)
|
||||
databaseStorage.write { transaction in
|
||||
callRecord.anyInsert(transaction: transaction)
|
||||
}
|
||||
call.callRecord = callRecord
|
||||
}
|
||||
|
||||
// Currently we just handle this as a hangup. But we could offer more descriptive action. e.g. DataChannel message
|
||||
handleLocalHungupCall(call)
|
||||
}
|
||||
|
||||
/**
|
||||
* Local user chose to end the call.
|
||||
*
|
||||
@ -1290,16 +1235,25 @@ private class SignalCallData: NSObject {
|
||||
|
||||
Logger.info("\(call.identifiersForLogs).")
|
||||
|
||||
call.state = .localHangup
|
||||
|
||||
if let callRecord = call.callRecord {
|
||||
if callRecord.callType == .outgoingIncomplete {
|
||||
callRecord.updateCallType(.outgoingMissed)
|
||||
}
|
||||
} else if call.state == .localRinging {
|
||||
// MJK TODO remove this timestamp param
|
||||
let callRecord = TSCall(timestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
callType: .incomingDeclined,
|
||||
in: call.thread)
|
||||
databaseStorage.write { transaction in
|
||||
callRecord.anyInsert(transaction: transaction)
|
||||
}
|
||||
call.callRecord = callRecord
|
||||
} else {
|
||||
owsFailDebug("missing call record")
|
||||
}
|
||||
|
||||
call.state = .localHangup
|
||||
|
||||
// TODO something like this lifted from Signal-Android.
|
||||
// this.accountManager.cancelInFlightRequests();
|
||||
// this.messageSender.cancelInFlightRequests();
|
||||
|
||||
@ -97,7 +97,13 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
self.callService.handleAnswerCall(call)
|
||||
}
|
||||
|
||||
func declineCall(localId: UUID) {
|
||||
func recipientAcceptedCall(_ call: SignalCall) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
self.audioSession.isRTCAudioEnabled = true
|
||||
}
|
||||
|
||||
func localHangupCall(localId: UUID) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
guard let call = self.callService.call else {
|
||||
@ -110,24 +116,7 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
|
||||
return
|
||||
}
|
||||
|
||||
self.declineCall(call)
|
||||
}
|
||||
|
||||
func declineCall(_ call: SignalCall) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
guard call.localId == self.callService.call?.localId else {
|
||||
owsFailDebug("localId does not match current call")
|
||||
return
|
||||
}
|
||||
|
||||
self.callService.handleDeclineCall(call)
|
||||
}
|
||||
|
||||
func recipientAcceptedCall(_ call: SignalCall) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
self.audioSession.isRTCAudioEnabled = true
|
||||
self.localHangupCall(call)
|
||||
}
|
||||
|
||||
func localHangupCall(_ call: SignalCall) {
|
||||
|
||||
@ -197,19 +197,6 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
callManager.answer(call: call)
|
||||
}
|
||||
|
||||
func declineCall(localId: UUID) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
owsFailDebug("CallKit should decline calls via system call screen, not via notifications.")
|
||||
}
|
||||
|
||||
func declineCall(_ call: SignalCall) {
|
||||
AssertIsOnMainThread()
|
||||
Logger.info("")
|
||||
|
||||
callManager.localHangup(call: call)
|
||||
}
|
||||
|
||||
func recipientAcceptedCall(_ call: SignalCall) {
|
||||
AssertIsOnMainThread()
|
||||
Logger.info("")
|
||||
@ -222,6 +209,12 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
|
||||
provider.reportCall(with: call.localId, updated: update)
|
||||
}
|
||||
|
||||
func localHangupCall(localId: UUID) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
owsFailDebug("CallKit should decline calls via system call screen, not via notifications.")
|
||||
}
|
||||
|
||||
func localHangupCall(_ call: SignalCall) {
|
||||
AssertIsOnMainThread()
|
||||
Logger.info("")
|
||||
|
||||
@ -19,9 +19,8 @@ protocol CallUIAdaptee {
|
||||
func reportMissedCall(_ call: SignalCall, callerName: String)
|
||||
func answerCall(localId: UUID)
|
||||
func answerCall(_ call: SignalCall)
|
||||
func declineCall(localId: UUID)
|
||||
func declineCall(_ call: SignalCall)
|
||||
func recipientAcceptedCall(_ call: SignalCall)
|
||||
func localHangupCall(localId: UUID)
|
||||
func localHangupCall(_ call: SignalCall)
|
||||
func remoteDidHangupCall(_ call: SignalCall)
|
||||
func remoteBusy(_ call: SignalCall)
|
||||
@ -197,18 +196,6 @@ extension CallUIAdaptee {
|
||||
adaptee.answerCall(call)
|
||||
}
|
||||
|
||||
@objc public func declineCall(localId: UUID) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
adaptee.declineCall(localId: localId)
|
||||
}
|
||||
|
||||
internal func declineCall(_ call: SignalCall) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
adaptee.declineCall(call)
|
||||
}
|
||||
|
||||
internal func didTerminateCall(_ call: SignalCall?) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
@ -241,6 +228,12 @@ extension CallUIAdaptee {
|
||||
adaptee.remoteBusy(call)
|
||||
}
|
||||
|
||||
internal func localHangupCall(localId: UUID) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
adaptee.localHangupCall(localId: localId)
|
||||
}
|
||||
|
||||
internal func localHangupCall(_ call: SignalCall) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user