diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index caaa3607c..21a700876 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -764,8 +764,6 @@ FD7162DB281B6C440060647B /* TypedTableAlias.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD7162DA281B6C440060647B /* TypedTableAlias.swift */; }; FD716E6428502DDD00C96BF4 /* CallManagerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD716E6328502DDD00C96BF4 /* CallManagerProtocol.swift */; }; FD716E6628502EE200C96BF4 /* CurrentCallProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD716E6528502EE200C96BF4 /* CurrentCallProtocol.swift */; }; - FD716E682850318E00C96BF4 /* CallMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD716E672850318E00C96BF4 /* CallMode.swift */; }; - FD716E6A2850327900C96BF4 /* EndCallMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD716E692850327900C96BF4 /* EndCallMode.swift */; }; FD716E6C28505E1C00C96BF4 /* MessageRequestsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD716E6B28505E1C00C96BF4 /* MessageRequestsViewModel.swift */; }; FD716E7128505E5200C96BF4 /* MessageRequestsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD716E7028505E5100C96BF4 /* MessageRequestsCell.swift */; }; FD716E722850647600C96BF4 /* Data+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD859EF127BF6BA200510D0C /* Data+Utilities.swift */; }; @@ -1951,8 +1949,6 @@ FD7162DA281B6C440060647B /* TypedTableAlias.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypedTableAlias.swift; sourceTree = ""; }; FD716E6328502DDD00C96BF4 /* CallManagerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallManagerProtocol.swift; sourceTree = ""; }; FD716E6528502EE200C96BF4 /* CurrentCallProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentCallProtocol.swift; sourceTree = ""; }; - FD716E672850318E00C96BF4 /* CallMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallMode.swift; sourceTree = ""; }; - FD716E692850327900C96BF4 /* EndCallMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndCallMode.swift; sourceTree = ""; }; FD716E6B28505E1C00C96BF4 /* MessageRequestsViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageRequestsViewModel.swift; sourceTree = ""; }; FD716E7028505E5100C96BF4 /* MessageRequestsCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageRequestsCell.swift; sourceTree = ""; }; FD72BD992BDF5EEA00CF6CF6 /* Message+Origin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Message+Origin.swift"; sourceTree = ""; }; @@ -2861,8 +2857,6 @@ B8DE1FB226C22F1F0079C9CE /* Calls */ = { isa = PBXGroup; children = ( - FD716E672850318E00C96BF4 /* CallMode.swift */, - FD716E692850327900C96BF4 /* EndCallMode.swift */, FD716E6528502EE200C96BF4 /* CurrentCallProtocol.swift */, FD716E6328502DDD00C96BF4 /* CallManagerProtocol.swift */, FD6C67232CF6E72900B350A7 /* NoopSessionCallManager.swift */, @@ -6106,7 +6100,6 @@ FD09B7E7288670FD00ED0B66 /* Reaction.swift in Sources */, FD245C5A2850660100B966DD /* LinkPreviewDraft.swift in Sources */, FDD82C3F2A205D0A00425F05 /* ProcessResult.swift in Sources */, - FD716E6A2850327900C96BF4 /* EndCallMode.swift in Sources */, FDF0B75C2807F41D004C14C5 /* MessageSender+Convenience.swift in Sources */, FD22726D2C32911C004D8A6C /* CheckForAppUpdatesJob.swift in Sources */, 7B81682A28B6F1420069F315 /* ReactionResponse.swift in Sources */, @@ -6224,7 +6217,6 @@ FD245C53285065DB00B966DD /* ProximityMonitoringManager.swift in Sources */, FD245C55285065E500B966DD /* OpenGroupManager.swift in Sources */, C32C599E256DB02B003C73A2 /* TypingIndicators.swift in Sources */, - FD716E682850318E00C96BF4 /* CallMode.swift in Sources */, FDE7549B2C940108002A2623 /* MessageViewModel+DeletionActions.swift in Sources */, FD09799527FE7B8E00936362 /* Interaction.swift in Sources */, FD37EA0D28AB2A45003AE748 /* _005_FixDeletedMessageReadState.swift in Sources */, diff --git a/Session/Calls/Call Management/SessionCall.swift b/Session/Calls/Call Management/SessionCall.swift index 23b62701a..c973039a2 100644 --- a/Session/Calls/Call Management/SessionCall.swift +++ b/Session/Calls/Call Management/SessionCall.swift @@ -22,8 +22,8 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { public let uuid: String public let callId: UUID // This is for CallKit public let sessionId: String + public let mode: CallMode let contactName: String - let mode: CallMode var audioMode: AudioMode let isOutgoing: Bool var remoteSDP: RTCSessionDescription? = nil { diff --git a/SessionMessagingKit/Calls/CallMode.swift b/SessionMessagingKit/Calls/CallMode.swift deleted file mode 100644 index 578b89ad4..000000000 --- a/SessionMessagingKit/Calls/CallMode.swift +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved. - -import Foundation - -public enum CallMode { - case offer - case answer -} diff --git a/SessionMessagingKit/Calls/CurrentCallProtocol.swift b/SessionMessagingKit/Calls/CurrentCallProtocol.swift index 2b811b4be..1016db0e2 100644 --- a/SessionMessagingKit/Calls/CurrentCallProtocol.swift +++ b/SessionMessagingKit/Calls/CurrentCallProtocol.swift @@ -5,14 +5,33 @@ import GRDB import WebRTC import SessionUtilitiesKit +// MARK: - CurrentCallProtocol + public protocol CurrentCallProtocol { var uuid: String { get } var callId: UUID { get } var sessionId: String { get } var hasStartedConnecting: Bool { get set } var hasEnded: Bool { get set } + var mode: CallMode { get } func updateCallMessage(mode: EndCallMode, using dependencies: Dependencies) func didReceiveRemoteSDP(sdp: RTCSessionDescription) func startSessionCall(_ db: Database) } + +// MARK: - CallMode + +public enum CallMode { + case offer + case answer +} + +// MARK: - EndCallMode + +public enum EndCallMode { + case local + case remote + case unanswered + case answeredElsewhere +} diff --git a/SessionMessagingKit/Calls/EndCallMode.swift b/SessionMessagingKit/Calls/EndCallMode.swift deleted file mode 100644 index fbf218ca1..000000000 --- a/SessionMessagingKit/Calls/EndCallMode.swift +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved. - -import Foundation - -public enum EndCallMode { - case local - case remote - case unanswered - case answeredElsewhere -} diff --git a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+Calls.swift b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+Calls.swift index 24943d33d..a20c3e0cf 100644 --- a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+Calls.swift +++ b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+Calls.swift @@ -176,7 +176,7 @@ extension MessageReceiver { else { return } guard sender != dependencies[cache: .general].sessionId.hexString else { - guard !currentCall.hasStartedConnecting else { return } + guard currentCall.mode == .answer && !currentCall.hasStartedConnecting else { return } dependencies[singleton: .callManager].dismissAllCallUI() dependencies[singleton: .callManager].reportCurrentCallEnded(reason: .answeredElsewhere) @@ -201,6 +201,7 @@ extension MessageReceiver { dependencies[singleton: .callManager].currentWebRTCSessionMatches(callId: message.uuid), let currentCall: CurrentCallProtocol = dependencies[singleton: .callManager].currentCall, currentCall.uuid == message.uuid, + !currentCall.hasEnded, let sender: String = message.sender else { return }