Skip to content

Commit e6013ee

Browse files
agent: allow passing specific server when creating the link
1 parent 1f173ab commit e6013ee

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/Simplex/Messaging/Agent.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ createConnection c nm userId enableNtfs checkNotices = withAgentEnv c .::. newCo
405405
-- Caller provides root signing key pair and link entity ID.
406406
-- Returns the created link and internal params.
407407
-- The link address is fully determined at this point.
408-
prepareConnectionLink :: AgentClient -> UserId -> C.KeyPairEd25519 -> ByteString -> Bool -> Maybe CRClientData -> AE (CreatedConnLink 'CMContact, PreparedLinkParams)
409-
prepareConnectionLink c userId rootKey linkEntityId checkNotices = withAgentEnv c . prepareConnectionLink' c userId rootKey linkEntityId checkNotices
408+
prepareConnectionLink :: AgentClient -> UserId -> C.KeyPairEd25519 -> ByteString -> Bool -> Maybe CRClientData -> Maybe SMPServerWithAuth -> AE (CreatedConnLink 'CMContact, PreparedLinkParams)
409+
prepareConnectionLink c userId rootKey linkEntityId checkNotices clientData srv_ = withAgentEnv c $ prepareConnectionLink' c userId rootKey linkEntityId checkNotices clientData srv_
410410
{-# INLINE prepareConnectionLink #-}
411411

412412
-- | Create connection for prepared link (single network call).
@@ -925,10 +925,10 @@ newConn c nm userId enableNtfs checkNotices cMode linkData_ clientData pqInitKey
925925

926926
-- | Prepare connection link for contact mode (no network, no database).
927927
-- Caller provides root signing key pair and link entity ID.
928-
prepareConnectionLink' :: AgentClient -> UserId -> C.KeyPairEd25519 -> ByteString -> Bool -> Maybe CRClientData -> AM (CreatedConnLink 'CMContact, PreparedLinkParams)
929-
prepareConnectionLink' c userId rootKey@(_, plpRootPrivKey) linkEntityId checkNotices clientData = do
928+
prepareConnectionLink' :: AgentClient -> UserId -> C.KeyPairEd25519 -> ByteString -> Bool -> Maybe CRClientData -> Maybe SMPServerWithAuth -> AM (CreatedConnLink 'CMContact, PreparedLinkParams)
929+
prepareConnectionLink' c userId rootKey@(_, plpRootPrivKey) linkEntityId checkNotices clientData srv_ = do
930930
g <- asks random
931-
plpSrvWithAuth@(ProtoServerWithAuth srv _) <- getSMPServer c userId
931+
plpSrvWithAuth@(ProtoServerWithAuth srv _) <- maybe (getSMPServer c userId) pure srv_
932932
when checkNotices $ checkClientNotices c plpSrvWithAuth
933933
AgentConfig {smpClientVRange, smpAgentVRange} <- asks config
934934
plpNonce@(C.CbNonce corrId) <- atomically $ C.randomCbNonce g

tests/AgentTests/FunctionalAPITests.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,7 @@ testPrepareCreateConnectionLink ps = withSmpServer ps $ withAgentClients2 $ \a b
16581658
linkEntId <- atomically $ C.randomBytes 32 g
16591659
runRight $ do
16601660
(ccLink@(CCLink connReq (Just shortLink)), preparedParams) <-
1661-
A.prepareConnectionLink a 1 rootKey linkEntId True Nothing
1661+
A.prepareConnectionLink a 1 rootKey linkEntId True Nothing Nothing
16621662
liftIO $ strDecode (strEncode shortLink) `shouldBe` Right shortLink
16631663
_ <- A.createConnectionForLink a NRMInteractive 1 True ccLink preparedParams userLinkData CR.IKPQOn SMSubscribe
16641664
(FixedLinkData {linkConnReq = connReq', linkEntityId}, ContactLinkData _ userCtData') <- getConnShortLink b 1 shortLink

0 commit comments

Comments
 (0)