mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-26 09:44:55 +00:00
core: remove unused events from api (#3764)
* core: remove unused events from api * fix test
This commit is contained in:
committed by
GitHub
parent
f2d498dd79
commit
a1328c287c
@@ -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
|
chatSendRemoteCmd cc rh s = J.encode . APIResponse Nothing rh <$> runReaderT (execChatCommand rh s) cc
|
||||||
|
|
||||||
chatRecvMsg :: ChatController -> IO JSONByteString
|
chatRecvMsg :: ChatController -> IO JSONByteString
|
||||||
chatRecvMsg ChatController {outputQ} = json <$> atomically (readTBQueue outputQ)
|
chatRecvMsg ChatController {outputQ} = json <$> readChatResponse
|
||||||
where
|
where
|
||||||
json (corr, remoteHostId, resp) = J.encode APIResponse {corr, remoteHostId, resp}
|
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 :: ChatController -> Int -> IO JSONByteString
|
||||||
chatRecvMsgWait cc time = fromMaybe "" <$> timeout time (chatRecvMsg cc)
|
chatRecvMsgWait cc time = fromMaybe "" <$> timeout time (chatRecvMsg cc)
|
||||||
|
|||||||
@@ -224,8 +224,6 @@ testChatApi tmp = do
|
|||||||
chatSendCmd cc "/_start" `shouldReturn` chatStarted
|
chatSendCmd cc "/_start" `shouldReturn` chatStarted
|
||||||
chatRecvMsg cc `shouldReturn` networkStatuses
|
chatRecvMsg cc `shouldReturn` networkStatuses
|
||||||
chatRecvMsg cc `shouldReturn` userContactSubSummary
|
chatRecvMsg cc `shouldReturn` userContactSubSummary
|
||||||
chatRecvMsg cc `shouldReturn` memberSubSummary
|
|
||||||
chatRecvMsgWait cc 10000 `shouldReturn` pendingSubSummary
|
|
||||||
chatRecvMsgWait cc 10000 `shouldReturn` ""
|
chatRecvMsgWait cc 10000 `shouldReturn` ""
|
||||||
chatParseMarkdown "hello" `shouldBe` "{}"
|
chatParseMarkdown "hello" `shouldBe` "{}"
|
||||||
chatParseMarkdown "*hello*" `shouldBe` parsedMarkdown
|
chatParseMarkdown "*hello*" `shouldBe` parsedMarkdown
|
||||||
|
|||||||
Reference in New Issue
Block a user