From d67554d78eeb81a0b1c4ac3a4cefd3bb8e7c219e Mon Sep 17 00:00:00 2001 From: "Evgeny @ SimpleX Chat" <259188159+evgeny-simplex@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:55:20 +0000 Subject: [PATCH] simplify createSndConn --- src/Simplex/Messaging/Agent/Store/AgentStore.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Messaging/Agent/Store/AgentStore.hs b/src/Simplex/Messaging/Agent/Store/AgentStore.hs index 72d15e274..19dea6e5b 100644 --- a/src/Simplex/Messaging/Agent/Store/AgentStore.hs +++ b/src/Simplex/Messaging/Agent/Store/AgentStore.hs @@ -568,11 +568,12 @@ updateNewConnSnd db connId sq = createSndConn :: DB.Connection -> TVar ChaChaDRG -> ConnData -> NewSndQueue -> IO (Either StoreError (ConnId, SndQueue)) createSndConn db gVar cData q@SndQueue {server} = -- check confirmed snd queue doesn't already exist, to prevent it being deleted by REPLACE in insertSndQueue_ - ifM (liftIO $ checkConfirmedSndQueueExists_ db q) (pure $ Left SESndQueueExists) $ - fmap (>>= sequence) . createConn_ db gVar cData $ \connId -> do + ifM (liftIO $ checkConfirmedSndQueueExists_ db q) (pure $ Left SESndQueueExists) . runExceptT $ do + (connId, sq) <- ExceptT . createConn_ db gVar cData $ \connId -> do serverKeyHash_ <- createServer db server createConnRecord db connId cData SCMInvitation insertSndQueue_ db connId q serverKeyHash_ + (connId,) <$> except sq createConnRecord :: DB.Connection -> ConnId -> ConnData -> SConnectionMode c -> IO () createConnRecord db connId ConnData {userId, connAgentVersion, enableNtfs, pqSupport, serviceRequestExpiresAt} cMode = do