Merge pull request #266 from simplex-chat/ep/fix-utf8-api

fix utf8 encoding for C API requests
This commit is contained in:
Evgeny Poberezkin
2022-02-04 12:46:45 +00:00
committed by GitHub
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -117,7 +117,7 @@ chatStart ChatStore {dbFilePrefix, chatStore} = do
pure cc
chatSendCmd :: ChatController -> String -> IO JSONString
chatSendCmd cc s = LB.unpack . J.encode . APIResponse Nothing <$> runReaderT (execChatCommand s) cc
chatSendCmd cc s = LB.unpack . J.encode . APIResponse Nothing <$> runReaderT (execChatCommand $ B.pack s) cc
chatRecvMsg :: ChatController -> IO JSONString
chatRecvMsg ChatController {outputQ} = json <$> atomically (readTBQueue outputQ)
+2 -1
View File
@@ -9,6 +9,7 @@ import Control.Monad.IO.Unlift
import Control.Monad.Reader
import Data.List (dropWhileEnd)
import qualified Data.Text as T
import Data.Text.Encoding (encodeUtf8)
import Simplex.Chat
import Simplex.Chat.Controller
import Simplex.Chat.Terminal.Output
@@ -29,7 +30,7 @@ runInputLoop ct = do
q <- asks inputQ
forever $ do
s <- atomically $ readTBQueue q
r <- execChatCommand s
r <- execChatCommand . encodeUtf8 $ T.pack s
liftIO . printToTerminal ct $ responseToView s r
runTerminalInput :: (MonadUnliftIO m, MonadReader ChatController m) => ChatTerminal -> m ()