From a1328c287c9c2bd4d975da4e81a7e0b4bdecfedc Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Fri, 26 Jan 2024 18:54:08 +0000 Subject: [PATCH] core: remove unused events from api (#3764) * core: remove unused events from api * fix test --- src/Simplex/Chat/Mobile.hs | 11 ++++++++++- tests/MobileTests.hs | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat/Mobile.hs b/src/Simplex/Chat/Mobile.hs index 57e062cd0..105dedb32 100644 --- a/src/Simplex/Chat/Mobile.hs +++ b/src/Simplex/Chat/Mobile.hs @@ -271,9 +271,18 @@ chatSendRemoteCmd :: ChatController -> Maybe RemoteHostId -> B.ByteString -> IO chatSendRemoteCmd cc rh s = J.encode . APIResponse Nothing rh <$> runReaderT (execChatCommand rh s) cc chatRecvMsg :: ChatController -> IO JSONByteString -chatRecvMsg ChatController {outputQ} = json <$> atomically (readTBQueue outputQ) +chatRecvMsg ChatController {outputQ} = json <$> readChatResponse where json (corr, remoteHostId, resp) = J.encode APIResponse {corr, remoteHostId, resp} + readChatResponse = do + out@(_, _, cr) <- atomically $ readTBQueue outputQ + if filterEvent cr then pure out else readChatResponse + filterEvent = \case + CRGroupSubscribed {} -> False + CRGroupEmpty {} -> False + CRMemberSubSummary {} -> False + CRPendingSubSummary {} -> False + _ -> True chatRecvMsgWait :: ChatController -> Int -> IO JSONByteString chatRecvMsgWait cc time = fromMaybe "" <$> timeout time (chatRecvMsg cc) diff --git a/tests/MobileTests.hs b/tests/MobileTests.hs index 2fb4446a6..f41d0172d 100644 --- a/tests/MobileTests.hs +++ b/tests/MobileTests.hs @@ -224,8 +224,6 @@ testChatApi tmp = do chatSendCmd cc "/_start" `shouldReturn` chatStarted chatRecvMsg cc `shouldReturn` networkStatuses chatRecvMsg cc `shouldReturn` userContactSubSummary - chatRecvMsg cc `shouldReturn` memberSubSummary - chatRecvMsgWait cc 10000 `shouldReturn` pendingSubSummary chatRecvMsgWait cc 10000 `shouldReturn` "" chatParseMarkdown "hello" `shouldBe` "{}" chatParseMarkdown "*hello*" `shouldBe` parsedMarkdown