diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index ef5e75176c..bd7ed16735 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -299,7 +299,7 @@ processAgentMessage user@User {userId, profile} agentConnId agentMessage = do agentMsgConnStatus :: ACommand 'Agent -> Maybe ConnStatus agentMsgConnStatus = \case - CONF _ _ -> Just ConnRequested + REQ _ _ -> Just ConnRequested INFO _ -> Just ConnSndReady CON -> Just ConnReady _ -> Nothing @@ -307,7 +307,7 @@ processAgentMessage user@User {userId, profile} agentConnId agentMessage = do processDirectMessage :: ACommand 'Agent -> Connection -> Maybe Contact -> m () processDirectMessage agentMsg conn = \case Nothing -> case agentMsg of - CONF confId connInfo -> do + REQ confId connInfo -> do saveConnInfo conn connInfo acceptAgentConnection conn confId $ XInfo profile INFO connInfo -> @@ -325,7 +325,7 @@ processAgentMessage user@User {userId, profile} agentConnId agentMessage = do XInfoProbeCheck probeHash -> xInfoProbeCheck ct probeHash XInfoProbeOk probe -> xInfoProbeOk ct probe _ -> pure () - CONF confId connInfo -> do + REQ confId connInfo -> do -- confirming direct connection with a member ChatMessage {chatMsgEvent} <- liftEither $ parseChatMessage connInfo case chatMsgEvent of @@ -333,7 +333,7 @@ processAgentMessage user@User {userId, profile} agentConnId agentMessage = do -- TODO check member ID -- TODO update member profile acceptAgentConnection conn confId XOk - _ -> messageError "CONF from member must have x.grp.mem.info" + _ -> messageError "REQ from member must have x.grp.mem.info" INFO connInfo -> do ChatMessage {chatMsgEvent} <- liftEither $ parseChatMessage connInfo case chatMsgEvent of @@ -361,7 +361,7 @@ processAgentMessage user@User {userId, profile} agentConnId agentMessage = do processGroupMessage :: ACommand 'Agent -> Connection -> GroupName -> GroupMember -> m () processGroupMessage agentMsg conn gName m = case agentMsg of - CONF confId connInfo -> do + REQ confId connInfo -> do ChatMessage {chatMsgEvent} <- liftEither $ parseChatMessage connInfo case memberCategory m of GCInviteeMember -> @@ -371,7 +371,7 @@ processAgentMessage user@User {userId, profile} agentConnId agentMessage = do withStore $ \st -> updateGroupMemberStatus st userId m GSMemAccepted acceptAgentConnection conn confId XOk | otherwise -> messageError "x.grp.acpt: memberId is different from expected" - _ -> messageError "CONF from invited member must have x.grp.acpt" + _ -> messageError "REQ from invited member must have x.grp.acpt" _ -> case chatMsgEvent of XGrpMemInfo memId _memProfile @@ -380,7 +380,7 @@ processAgentMessage user@User {userId, profile} agentConnId agentMessage = do Group {membership} <- withStore $ \st -> getGroup st user gName acceptAgentConnection conn confId $ XGrpMemInfo (memberId membership) profile | otherwise -> messageError "x.grp.mem.info: memberId is different from expected" - _ -> messageError "CONF from member must have x.grp.mem.info" + _ -> messageError "REQ from member must have x.grp.mem.info" INFO connInfo -> do ChatMessage {chatMsgEvent} <- liftEither $ parseChatMessage connInfo case chatMsgEvent of @@ -648,7 +648,7 @@ sendGroupMessage members chatMsgEvent = do acceptAgentConnection :: ChatMonad m => Connection -> ConfirmationId -> ChatMsgEvent -> m () acceptAgentConnection conn@Connection {agentConnId} confId msg = do - withAgent $ \a -> allowConnection a agentConnId confId $ directMessage msg + withAgent $ \a -> acceptConnection a agentConnId confId $ directMessage msg withStore $ \st -> updateConnectionStatus st conn ConnAccepted getCreateActiveUser :: SQLiteStore -> IO User diff --git a/stack.yaml b/stack.yaml index 3e8e8b2c75..93b83465d7 100644 --- a/stack.yaml +++ b/stack.yaml @@ -43,7 +43,7 @@ extra-deps: # - simplexmq-0.3.1@sha256:f247aaff3c16c5d3974a4ab4d5882ab50ac78073110997c0bceb05a74d10a325,6688 # - ../simplexmq - github: simplex-chat/simplexmq - commit: 8a4bced56972363c073c05bf81ecc0a3b1c2cd8d + commit: 703450d78e812a304e00fc59d09cc4316faf673d # this commit is in PR #164 # # extra-deps: [] diff --git a/tests/ChatTests.hs b/tests/ChatTests.hs index affe3d68fe..22ca888e53 100644 --- a/tests/ChatTests.hs +++ b/tests/ChatTests.hs @@ -36,7 +36,7 @@ chatTests = do it "add contacts, create group and send/receive messages" testGroup it "create and join group with 4 members" testGroup2 it "create and delete group" testGroupDelete - fit "remove contact from group and add again" testGroupRemoveAdd + it "remove contact from group and add again" testGroupRemoveAdd testAddContact :: IO () testAddContact = @@ -417,11 +417,9 @@ getWindow (TestCC _ t _) = do let w = virtualWindow t win <- readTVarIO w -- TODO to debug - putStrLn (lastOutput 1 win') - before returning it - r <- atomically $ do + atomically $ do win' <- readTVar w if win' /= win then pure win' else retry - putStrLn $ lastOutput 1 r - pure r invitation :: [String] -> Maybe String invitation win = lastMaybe $ map (dropWhileEnd (== ' ')) $ filter ("smp::" `isPrefixOf`) win