diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 477b71a16d..79e7d33325 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -2463,7 +2463,7 @@ chatCommandP = "/_db import " *> (APIImportArchive <$> jsonP), "/_db delete" $> APIDeleteStorage, "/_get chats" *> (APIGetChats <$> (" pcc=on" $> True <|> " pcc=off" $> False <|> pure False)), - "/_get chat " *> (APIGetChat <$> chatRefP <* A.space <*> chatPaginationP <*> optional (A.space *> search)), + "/_get chat " *> (APIGetChat <$> chatRefP <* A.space <*> chatPaginationP <*> optional searchP), "/_get items count=" *> (APIGetChatItems <$> A.decimal), "/_send " *> (APISendMessage <$> chatRefP <*> (" json " *> jsonP <|> " text " *> (ComposedMessage Nothing Nothing <$> mcTextP))), "/_update item " *> (APIUpdateChatItem <$> chatRefP <* A.space <*> A.decimal <* A.space <*> msgContentP), @@ -2592,7 +2592,7 @@ chatCommandP = n <- (A.space *> A.takeByteString) <|> pure "" pure $ if B.null n then name else safeDecodeUtf8 n filePath = T.unpack . safeDecodeUtf8 <$> A.takeByteString - search = T.unpack . safeDecodeUtf8 <$> A.takeByteString + searchP = T.unpack . safeDecodeUtf8 <$> (" search=" *> A.takeByteString) memberRole = (" owner" $> GROwner) <|> (" admin" $> GRAdmin) diff --git a/tests/ChatTests.hs b/tests/ChatTests.hs index 046ee25cf0..c44a49bfca 100644 --- a/tests/ChatTests.hs +++ b/tests/ChatTests.hs @@ -212,7 +212,7 @@ testAddContact = versionTestMatrix2 runTestAddContact alice #$> ("/_get chat @2 after=1 count=100", chat, [(0, "hello there"), (0, "how are you?")]) alice #$> ("/_get chat @2 before=2 count=100", chat, [(1, "hello there 🙂")]) -- search - alice #$> ("/_get chat @2 count=100 ello ther", chat, [(1, "hello there 🙂"), (0, "hello there")]) + alice #$> ("/_get chat @2 count=100 search=ello ther", chat, [(1, "hello there 🙂"), (0, "hello there")]) -- read messages alice #$> ("/_read chat @2 from=1 to=100", id, "ok") bob #$> ("/_read chat @2 from=1 to=100", id, "ok") @@ -479,7 +479,7 @@ testGroupShared alice bob cath checkMessages = do -- so we take into account group event items as well as sent group invitations in direct chats alice #$> ("/_get chat #1 after=5 count=100", chat, [(0, "hi there"), (0, "hey team")]) alice #$> ("/_get chat #1 before=7 count=100", chat, [(0, "connected"), (0, "connected"), (1, "hello"), (0, "hi there")]) - alice #$> ("/_get chat #1 count=100 team", chat, [(0, "hey team")]) + alice #$> ("/_get chat #1 count=100 search=team", chat, [(0, "hey team")]) bob @@@ [("@cath", "hey"), ("#team", "hey team"), ("@alice", "received invitation to join group team as admin")] bob #$> ("/_get chat #1 count=100", chat, [(0, "connected"), (0, "added cath (Catherine)"), (0, "connected"), (0, "hello"), (1, "hi there"), (0, "hey team")]) cath @@@ [("@bob", "hey"), ("#team", "hey team"), ("@alice", "received invitation to join group team as admin")]