Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/Simplex/Messaging/Agent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module Simplex.Messaging.Agent
deleteConnectionAsync,
deleteConnectionsAsync,
createConnection,
createConnectionOnServer,
prepareConnectionLink,
createConnectionForLink,
setConnShortLink,
Expand Down Expand Up @@ -398,9 +399,16 @@ deleteConnectionsAsync c waitDelivery = withAgentEnv c . deleteConnectionsAsync'

-- | Create SMP agent connection (NEW command)
createConnection :: ConnectionModeI c => AgentClient -> NetworkRequestMode -> UserId -> Bool -> Bool -> SConnectionMode c -> Maybe (UserConnLinkData c) -> Maybe CRClientData -> CR.InitialKeys -> SubscriptionMode -> AE (ConnId, (CreatedConnLink c, Maybe ClientServiceId))
createConnection c nm userId enableNtfs checkNotices = withAgentEnv c .::. newConn c nm userId enableNtfs checkNotices
createConnection c nm userId enableNtfs checkNotices cMode linkData_ clientData pqInitKeys subMode =
withAgentEnv c $ newConn c nm userId enableNtfs checkNotices cMode linkData_ clientData Nothing pqInitKeys subMode
{-# INLINE createConnection #-}

-- | Create SMP agent connection on a specific SMP server.
createConnectionOnServer :: ConnectionModeI c => AgentClient -> NetworkRequestMode -> UserId -> Bool -> Bool -> SConnectionMode c -> Maybe (UserConnLinkData c) -> Maybe CRClientData -> Maybe SMPServerWithAuth -> CR.InitialKeys -> SubscriptionMode -> AE (ConnId, (CreatedConnLink c, Maybe ClientServiceId))
createConnectionOnServer c nm userId enableNtfs checkNotices cMode linkData_ clientData srv_ pqInitKeys subMode =
withAgentEnv c $ newConn c nm userId enableNtfs checkNotices cMode linkData_ clientData srv_ pqInitKeys subMode
{-# INLINE createConnectionOnServer #-}

-- | Prepare connection link for contact mode (no network call).
-- Caller provides root signing key pair and link entity ID.
-- Returns the created link and internal params.
Expand Down Expand Up @@ -914,9 +922,9 @@ switchConnectionAsync' c corrId connId =
connectionStats c $ DuplexConnection cData rqs' sqs
_ -> throwE $ CMD PROHIBITED "switchConnectionAsync: not duplex"

newConn :: ConnectionModeI c => AgentClient -> NetworkRequestMode -> UserId -> Bool -> Bool -> SConnectionMode c -> Maybe (UserConnLinkData c) -> Maybe CRClientData -> CR.InitialKeys -> SubscriptionMode -> AM (ConnId, (CreatedConnLink c, Maybe ClientServiceId))
newConn c nm userId enableNtfs checkNotices cMode linkData_ clientData pqInitKeys subMode = do
srv <- getSMPServer c userId
newConn :: ConnectionModeI c => AgentClient -> NetworkRequestMode -> UserId -> Bool -> Bool -> SConnectionMode c -> Maybe (UserConnLinkData c) -> Maybe CRClientData -> Maybe SMPServerWithAuth -> CR.InitialKeys -> SubscriptionMode -> AM (ConnId, (CreatedConnLink c, Maybe ClientServiceId))
newConn c nm userId enableNtfs checkNotices cMode linkData_ clientData srv_ pqInitKeys subMode = do
srv <- maybe (getSMPServer c userId) pure srv_
when (checkNotices && connMode cMode == CMContact) $ checkClientNotices c srv
connId <- newConnNoQueues c userId enableNtfs cMode (CR.connPQEncryption pqInitKeys)
(connId,)
Expand Down
Loading