mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-09 09:35:55 +00:00
core: drop agent versions in simplexmq (#7360)
* core: adapt to dropped agent versions * refactor * remove comments * api types, protocol tests * fix test --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
@@ -1697,7 +1697,7 @@ processChatCommand cxt nm = \case
|
||||
Just RelayAddressLinkData {relayProfile} -> do
|
||||
let failWithProfile step e =
|
||||
pure $ CRChatRelayTestResult user (Just relayProfile) (Just $ RelayTestFailure step e)
|
||||
lift (withAgent' $ \a -> connRequestPQSupport a PQSupportOff cReq) >>= \case
|
||||
lift (withAgent' (`connRequestAgentVersion` cReq)) >>= \case
|
||||
Nothing -> failWithProfile RTSConnect (ChatError $ CERelayTestError "invalid connection request")
|
||||
Just _ -> do
|
||||
let chatV = initialChatVersion
|
||||
@@ -3378,7 +3378,7 @@ processChatCommand cxt nm = \case
|
||||
_ -> throwChatError $ CEException "connection already started (past prepared status)"
|
||||
where
|
||||
joinNewConn subMode = do
|
||||
-- possible improvement: use agent connRequestPQSupport to determine pqSupport here;
|
||||
-- possible improvement: use agent connRequestAgentVersion to determine pqSupport here;
|
||||
-- for joinPreparedConn below - same + encodeConnInfoPQ;
|
||||
-- same for auto-accept on xGrpDirectInv
|
||||
acId <- withAgent $ \a -> prepareConnectionToJoin a (aUserId user) True cReq PQSupportOff
|
||||
@@ -3766,10 +3766,10 @@ processChatCommand cxt nm = \case
|
||||
connectViaInvitation user@User {userId} incognito (CCLink cReq@(CRInvitationUri crData e2e) sLnk_) contactId_ =
|
||||
withInvitationLock "connect" (strEncode cReq) $ do
|
||||
subMode <- chatReadVar subscriptionMode
|
||||
lift (withAgent' $ \a -> connRequestPQSupport a PQSupportOn cReq) >>= \case
|
||||
lift (withAgent' (`connRequestAgentVersion` cReq)) >>= \case
|
||||
Nothing -> throwChatError CEInvalidConnReq
|
||||
-- TODO PQ the error above should be CEIncompatibleConnReqVersion, also the same API should be called in Plan
|
||||
Just (_, pqSup') -> do
|
||||
Just _ -> do
|
||||
let chatV = initialChatVersion
|
||||
withFastStore' (\db -> getConnectionEntityByConnReq db cxt user cReqs) >>= \case
|
||||
Nothing -> joinNewConn chatV
|
||||
@@ -3780,6 +3780,8 @@ processChatCommand cxt nm = \case
|
||||
joinPreparedConn conn (fromLocalProfile <$> localIncognitoProfile)
|
||||
Just ent -> throwCmdError $ "connection is not RcvDirectMsgConnection: " <> show (connEntityInfo ent)
|
||||
where
|
||||
-- all supported versions support PQ encryption
|
||||
pqSup' = PQSupportOn
|
||||
joinNewConn chatV = do
|
||||
-- [incognito] generate profile to send
|
||||
incognitoProfile <- if incognito then Just <$> liftIO generateRandomProfile else pure Nothing
|
||||
@@ -3926,10 +3928,7 @@ processChatCommand cxt nm = \case
|
||||
_ -> pure ()
|
||||
prepareContact :: User -> ConnReqContact -> PQSupport -> CM (ConnId, VersionChat)
|
||||
prepareContact user cReq pqSup = do
|
||||
-- 0) toggle disabled - PQSupportOff
|
||||
-- 1) toggle enabled, address supports PQ (connRequestPQSupport returns Just True) - PQSupportOn, enable support with compression
|
||||
-- 2) toggle enabled, address doesn't support PQ - PQSupportOn but without compression, with version range indicating support
|
||||
lift (withAgent' $ \a -> connRequestPQSupport a pqSup cReq) >>= \case
|
||||
lift (withAgent' (`connRequestAgentVersion` cReq)) >>= \case
|
||||
Nothing -> throwChatError CEInvalidConnReq
|
||||
Just _ -> do
|
||||
let chatV = initialChatVersion
|
||||
@@ -4259,7 +4258,7 @@ processChatCommand cxt nm = \case
|
||||
addRelay :: UserChatRelay -> CM (UserChatRelay, Either ChatError GroupRelay)
|
||||
addRelay relay@UserChatRelay {address} = fmap (relay,) . tryAllErrors $ do
|
||||
(_, _, cReq) <- getShortLinkConnReq nm user address
|
||||
lift (withAgent' $ \a -> connRequestPQSupport a PQSupportOff cReq) >>= \case
|
||||
lift (withAgent' (`connRequestAgentVersion` cReq)) >>= \case
|
||||
Nothing -> throwChatError CEInvalidConnReq
|
||||
Just _ -> do
|
||||
let chatV = initialChatVersion
|
||||
|
||||
@@ -2940,8 +2940,7 @@ connRequestPQEncryption = \case
|
||||
CRContactUri _ rks -> pqEnc . snd <$> rks
|
||||
CRInvitationUri _ e2e -> Just $ pqEnc e2e
|
||||
where
|
||||
pqEnc (CR.E2ERatchetParamsUri vr' _ _ pq) =
|
||||
PQEncryption $ maxVersion vr' >= CR.pqRatchetE2EEncryptVersion && isJust pq
|
||||
pqEnc (CR.E2ERatchetParamsUri _ _ _ pq) = PQEncryption $ isJust pq
|
||||
|
||||
createRcvFeatureItems :: User -> Contact -> Contact -> CM' ()
|
||||
createRcvFeatureItems user ct ct' =
|
||||
|
||||
@@ -1201,7 +1201,7 @@ processAgentMessageConn cxt user@User {userId} corrId agentConnId agentMessage =
|
||||
case cReq of
|
||||
CRContactUri crData@ConnReqUriData {crClientData} e2e -> do
|
||||
let pqSup = PQSupportOff
|
||||
lift (withAgent' $ \a -> connRequestPQSupport a pqSup cReq) >>= \case
|
||||
lift (withAgent' (`connRequestAgentVersion` cReq)) >>= \case
|
||||
Nothing -> throwChatError CEInvalidConnReq
|
||||
Just _ -> do
|
||||
let chatV = initialChatVersion
|
||||
|
||||
@@ -199,7 +199,7 @@ createConnReqConnection db userId acId preparedEntity_ cReq cReqHash sLnk xConta
|
||||
-- TODO (proposed):
|
||||
-- - add agent version 8 for short links
|
||||
-- - update agentToChatVersion to convert 8 to 16
|
||||
-- - return and correctly set peer's range from link (via connRequestPQSupport)
|
||||
-- - return and correctly set peer's range from link (via connRequestAgentVersion)
|
||||
peerChatVRange = chatInitialVRange, -- this is 1-1
|
||||
connLevel = 0,
|
||||
viaContact = Nothing,
|
||||
|
||||
Reference in New Issue
Block a user