From 65bb3d2bbda05eec7906e2a9f6a3809e1250577f Mon Sep 17 00:00:00 2001 From: IC Rainbow Date: Thu, 4 Jan 2024 18:14:35 +0200 Subject: [PATCH] switch to * for chat type sigil --- src/Simplex/Chat.hs | 8 ++-- src/Simplex/Chat/Messages.hs | 2 +- src/Simplex/Chat/View.hs | 10 ++--- tests/ChatTests/ChatList.hs | 14 +++--- tests/ChatTests/Direct.hs | 6 +-- tests/ChatTests/Local.hs | 84 ++++++++++++++++++------------------ tests/ChatTests/Utils.hs | 8 ++-- 7 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 280dbd0458..53cc17e386 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -6294,7 +6294,7 @@ chatCommandP = "/_get items " *> (APIGetChatItems <$> chatPaginationP <*> optional (" search=" *> stringP)), "/_get item info " *> (APIGetChatItemInfo <$> chatRefP <* A.space <*> A.decimal), "/_send " *> (APISendMessage <$> chatRefP <*> liveMessageP <*> sendMessageTTLP <*> (" json " *> jsonP <|> " text " *> (ComposedMessage Nothing Nothing <$> mcTextP))), - "/_create -" *> (APICreateChatItem <$> A.decimal <*> (" json " *> jsonP <|> " text " *> (ComposedMessage Nothing Nothing <$> mcTextP))), + "/_create *" *> (APICreateChatItem <$> A.decimal <*> (" json " *> jsonP <|> " text " *> (ComposedMessage Nothing Nothing <$> mcTextP))), "/_update item " *> (APIUpdateChatItem <$> chatRefP <* A.space <*> A.decimal <*> liveMessageP <* A.space <*> msgContentP), "/_delete item " *> (APIDeleteChatItem <$> chatRefP <* A.space <*> A.decimal <* A.space <*> ciDeleteMode), "/_delete member item #" *> (APIDeleteMemberChatItem <$> A.decimal <* A.space <*> A.decimal <* A.space <*> A.decimal), @@ -6403,7 +6403,7 @@ chatCommandP = ("/leave " <|> "/l ") *> char_ '#' *> (LeaveGroup <$> displayName), ("/delete #" <|> "/d #") *> (DeleteGroup <$> displayName), ("/delete " <|> "/d ") *> char_ '@' *> (DeleteContact <$> displayName), - "/clear -" $> ClearNoteFolder "", + "/clear *" $> ClearNoteFolder "", "/clear #" *> (ClearGroup <$> displayName), "/clear " *> char_ '@' *> (ClearContact <$> displayName), ("/members " <|> "/ms ") *> char_ '#' *> (ListMembers <$> displayName), @@ -6437,7 +6437,7 @@ chatCommandP = ("/connect" <|> "/c") *> (Connect <$> incognitoP <* A.space <*> ((Just <$> strP) <|> A.takeTill isSpace $> Nothing)), ("/connect" <|> "/c") *> (AddContact <$> incognitoP), SendMessage <$> chatNameP <* A.space <*> msgTextP, - "/- " *> (SendMessage (ChatName CTLocal "") <$> msgTextP), + "/* " *> (SendMessage (ChatName CTLocal "") <$> msgTextP), "@#" *> (SendMemberContactMessage <$> displayName <* A.space <* char_ '@' <*> displayName <* A.space <*> msgTextP), "/live " *> (SendLiveMessage <$> chatNameP <*> (A.space *> msgTextP <|> pure "")), (">@" <|> "> @") *> sendMsgQuote (AMsgDirection SMDRcv), @@ -6528,7 +6528,7 @@ chatCommandP = incognitoOnOffP = (A.space *> "incognito=" *> onOffP) <|> pure False imagePrefix = (<>) <$> "data:" <*> ("image/png;base64," <|> "image/jpg;base64,") imageP = safeDecodeUtf8 <$> ((<>) <$> imagePrefix <*> (B64.encode <$> base64P)) - chatTypeP = A.char '@' $> CTDirect <|> A.char '#' $> CTGroup <|> A.char '-' $> CTLocal <|> A.char ':' $> CTContactConnection + chatTypeP = A.char '@' $> CTDirect <|> A.char '#' $> CTGroup <|> A.char '*' $> CTLocal <|> A.char ':' $> CTContactConnection chatPaginationP = (CPLast <$ "count=" <*> A.decimal) <|> (CPAfter <$ "after=" <*> A.decimal <* A.space <* "count=" <*> A.decimal) diff --git a/src/Simplex/Chat/Messages.hs b/src/Simplex/Chat/Messages.hs index fb876096a8..3925a0c57e 100644 --- a/src/Simplex/Chat/Messages.hs +++ b/src/Simplex/Chat/Messages.hs @@ -64,7 +64,7 @@ chatTypeStr :: ChatType -> Text chatTypeStr = \case CTDirect -> "@" CTGroup -> "#" - CTLocal -> "-" + CTLocal -> "*" CTContactRequest -> "<@" CTContactConnection -> ":" diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 80ce70877f..fcb9f6f458 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -395,7 +395,7 @@ responseToView hu@(currentRH, user_) ChatConfig {logLevel, showReactions, showRe toChatView :: AChat -> (Text, Text, Maybe ConnStatus) toChatView (AChat _ (Chat (DirectChat Contact {localDisplayName, activeConn}) items _)) = ("@" <> localDisplayName, toCIPreview items Nothing, connStatus <$> activeConn) toChatView (AChat _ (Chat (GroupChat GroupInfo {membership, localDisplayName}) items _)) = ("#" <> localDisplayName, toCIPreview items (Just membership), Nothing) - toChatView (AChat _ (Chat (LocalChat _) items _)) = ("-", toCIPreview items Nothing, Nothing) + toChatView (AChat _ (Chat (LocalChat _) items _)) = ("*", toCIPreview items Nothing, Nothing) toChatView (AChat _ (Chat (ContactRequest UserContactRequest {localDisplayName}) items _)) = ("<@" <> localDisplayName, toCIPreview items Nothing, Nothing) toChatView (AChat _ (Chat (ContactConnection PendingContactConnection {pccConnId, pccConnStatus}) items _)) = (":" <> T.pack (show pccConnId), toCIPreview items Nothing, Just pccConnStatus) toCIPreview :: [CChatItem c] -> Maybe GroupMember -> Text @@ -560,14 +560,14 @@ viewChatItem chat ci@ChatItem {chatDir, meta = meta@CIMeta {forwardedByMember}, CISndGroupEvent {} -> showSndItemProhibited to _ -> showSndItem to where - to = "- " + to = "* " CILocalRcv -> case content of CIRcvMsgContent mc -> withLocalFile from $ rcvMsg from quote mc CIRcvIntegrityError err -> viewRcvIntegrityError from err ts tz meta CIRcvGroupEvent {} -> showRcvItemProhibited from _ -> showRcvItem from where - from = "- " + from = "* " where quote = [] ContactRequest {} -> [] @@ -728,7 +728,7 @@ viewItemReaction showReactions chat CIReaction {chatDir, chatItem = CChatItem md Just mc -> view from $ reactionMsg mc _ -> [] where - from = "- " + from = "* " reactionMsg mc = quoteText mc $ if toMsgDirection md == MDSnd then ">>" else ">" (_, CIDirectSnd) -> [sentText] (_, CIGroupSnd) -> [sentText] @@ -2023,7 +2023,7 @@ ttyGroup' :: GroupInfo -> StyledString ttyGroup' = ttyGroup . groupName' ttyLocal :: NoteFolderName -> StyledString -ttyLocal l = styled (colored Green) $ "-" <> viewName l +ttyLocal l = styled (colored Green) $ "*" <> viewName l viewContactName :: Contact -> Text viewContactName = viewName . localDisplayName' diff --git a/tests/ChatTests/ChatList.hs b/tests/ChatTests/ChatList.hs index 6066b92b8f..b3f94a9594 100644 --- a/tests/ChatTests/ChatList.hs +++ b/tests/ChatTests/ChatList.hs @@ -193,20 +193,20 @@ testPaginationAllChatTypes = _ts6 <- iso8601Show <$> getCurrentTime - -- -notes + -- * (notes) createCCNoteFolder alice - alice /- "psst" + alice /* "psst" ts7 <- iso8601Show <$> getCurrentTime - getChats_ alice "count=10" [("-", "psst"), ("@dan", "hey"), ("#team", ""), (":3", ""), ("<@cath", ""), ("@bob", "hey")] - getChats_ alice "count=3" [("-", "psst"), ("@dan", "hey"), ("#team", "")] + getChats_ alice "count=10" [("*", "psst"), ("@dan", "hey"), ("#team", ""), (":3", ""), ("<@cath", ""), ("@bob", "hey")] + getChats_ alice "count=3" [("*", "psst"), ("@dan", "hey"), ("#team", "")] getChats_ alice ("after=" <> ts2 <> " count=2") [(":3", ""), ("<@cath", "")] getChats_ alice ("before=" <> ts5 <> " count=2") [("#team", ""), (":3", "")] - getChats_ alice ("after=" <> ts3 <> " count=10") [("-", "psst"), ("@dan", "hey"), ("#team", ""), (":3", "")] + getChats_ alice ("after=" <> ts3 <> " count=10") [("*", "psst"), ("@dan", "hey"), ("#team", ""), (":3", "")] getChats_ alice ("before=" <> ts4 <> " count=10") [(":3", ""), ("<@cath", ""), ("@bob", "hey")] - getChats_ alice ("after=" <> ts1 <> " count=10") [("-", "psst"), ("@dan", "hey"), ("#team", ""), (":3", ""), ("<@cath", ""), ("@bob", "hey")] - getChats_ alice ("before=" <> ts7 <> " count=10") [("-", "psst"), ("@dan", "hey"), ("#team", ""), (":3", ""), ("<@cath", ""), ("@bob", "hey")] + getChats_ alice ("after=" <> ts1 <> " count=10") [("*", "psst"), ("@dan", "hey"), ("#team", ""), (":3", ""), ("<@cath", ""), ("@bob", "hey")] + getChats_ alice ("before=" <> ts7 <> " count=10") [("*", "psst"), ("@dan", "hey"), ("#team", ""), (":3", ""), ("<@cath", ""), ("@bob", "hey")] getChats_ alice ("after=" <> ts7 <> " count=10") [] getChats_ alice ("before=" <> ts1 <> " count=10") [] diff --git a/tests/ChatTests/Direct.hs b/tests/ChatTests/Direct.hs index 8adf33c9d7..1c2b4b644d 100644 --- a/tests/ChatTests/Direct.hs +++ b/tests/ChatTests/Direct.hs @@ -1386,14 +1386,14 @@ testMultipleUserAddresses = cLinkAlisa <- getContactLink alice True bob ##> ("/c " <> cLinkAlisa) alice <#? bob - alice #$> ("/_get chats 2 pcc=on", chats, [("<@bob", ""), ("-", "")]) + alice #$> ("/_get chats 2 pcc=on", chats, [("<@bob", ""), ("*", "")]) alice ##> "/ac bob" alice <## "bob (Bob): accepting contact request..." concurrently_ (bob <## "alisa: contact is connected") (alice <## "bob (Bob): contact is connected") threadDelay 100000 - alice #$> ("/_get chats 2 pcc=on", chats, [("@bob", lastChatFeature), ("-", "")]) + alice #$> ("/_get chats 2 pcc=on", chats, [("@bob", lastChatFeature), ("*", "")]) alice <##> bob bob #> "@alice hey alice" @@ -1424,7 +1424,7 @@ testMultipleUserAddresses = (cath <## "alisa: contact is connected") (alice <## "cath (Catherine): contact is connected") threadDelay 100000 - alice #$> ("/_get chats 2 pcc=on", chats, [("@cath", lastChatFeature), ("@bob", "hey"), ("-", "")]) + alice #$> ("/_get chats 2 pcc=on", chats, [("@cath", lastChatFeature), ("@bob", "hey"), ("*", "")]) alice <##> cath -- first user doesn't have cath as contact diff --git a/tests/ChatTests/Local.hs b/tests/ChatTests/Local.hs index 4d7e25ac7d..5245829c00 100644 --- a/tests/ChatTests/Local.hs +++ b/tests/ChatTests/Local.hs @@ -28,35 +28,35 @@ testNotes tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do alice ##> "/contacts" -- not a contact - alice /- "keep in mind" + alice /* "keep in mind" alice ##> "/tail" - alice <# "- keep in mind" + alice <# "* keep in mind" alice ##> "/chats" - alice <# "- keep in mind" + alice <# "* keep in mind" alice ##> "/? keep" - alice <# "- keep in mind" + alice <# "* keep in mind" - alice #$> ("/_read chat -1 from=1 to=100", id, "ok") - alice ##> "/_unread chat -1 on" + alice #$> ("/_read chat *1 from=1 to=100", id, "ok") + alice ##> "/_unread chat *1 on" alice <## "ok" - alice ##> "/_delete item -1 1 internal" + alice ##> "/_delete item *1 1 internal" alice <## "message deleted" alice ##> "/tail" alice ##> "/chats" - alice /- "ahoy!" - alice ##> "/_update item -1 1 text Greetings." - alice ##> "/tail -" - alice <# "- Greetings." + alice /* "ahoy!" + alice ##> "/_update item *1 1 text Greetings." + alice ##> "/tail *" + alice <# "* Greetings." testUserNotes :: FilePath -> IO () testUserNotes tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do createCCNoteFolder alice - alice /- "keep in mind" + alice /* "keep in mind" alice ##> "/tail" - alice <# "- keep in mind" + alice <# "* keep in mind" alice ##> "/create user secret" alice <## "user profile: secret" @@ -65,7 +65,7 @@ testUserNotes tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do alice ##> "/tail" - alice ##> "/_delete item -1 1 internal" + alice ##> "/_delete item *1 1 internal" alice <## "chat db error: SENoteFolderNotFound {noteFolderId = 1}" testPreviewsPagination :: FilePath -> IO () @@ -73,38 +73,38 @@ testPreviewsPagination tmp = withNewTestChat tmp "alice" aliceProfile $ \alice - createCCNoteFolder alice tsS <- iso8601Show <$> getCurrentTime - alice /- "first" + alice /* "first" tsM <- iso8601Show <$> getCurrentTime - alice /- "last" + alice /* "last" tsE <- iso8601Show <$> getCurrentTime -- there's only one folder that got updated after tsM and before tsE - getChats_ alice "count=3" [("-", "last")] + getChats_ alice "count=3" [("*", "last")] getChats_ alice ("after=" <> tsE <> " count=10") [] - getChats_ alice ("after=" <> tsS <> " count=10") [("-", "last")] + getChats_ alice ("after=" <> tsS <> " count=10") [("*", "last")] getChats_ alice ("before=" <> tsM <> " count=10") [] - getChats_ alice ("before=" <> tsE <> " count=10") [("-", "last")] + getChats_ alice ("before=" <> tsE <> " count=10") [("*", "last")] getChats_ alice ("before=" <> tsS <> " count=10") [] testChatPagination :: FilePath -> IO () testChatPagination tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do createCCNoteFolder alice - alice /- "hello world" - alice /- "memento mori" - alice /- "knock-knock" - alice /- "who's there?" + alice /* "hello world" + alice /* "memento mori" + alice /* "knock-knock" + alice /* "who's there?" - alice #$> ("/_get chat -1 count=100", chat, [(1, "hello world"), (1, "memento mori"), (1, "knock-knock"), (1, "who's there?")]) - alice #$> ("/_get chat -1 count=1", chat, [(1, "who's there?")]) - alice #$> ("/_get chat -1 after=2 count=10", chat, [(1, "knock-knock"), (1, "who's there?")]) - alice #$> ("/_get chat -1 after=2 count=2", chat, [(1, "knock-knock"), (1, "who's there?")]) - alice #$> ("/_get chat -1 after=1 count=2", chat, [(1, "memento mori"), (1, "knock-knock")]) - alice #$> ("/_get chat -1 before=3 count=10", chat, [(1, "hello world"), (1, "memento mori")]) - alice #$> ("/_get chat -1 before=3 count=2", chat, [(1, "hello world"), (1, "memento mori")]) - alice #$> ("/_get chat -1 before=4 count=2", chat, [(1, "memento mori"), (1, "knock-knock")]) + alice #$> ("/_get chat *1 count=100", chat, [(1, "hello world"), (1, "memento mori"), (1, "knock-knock"), (1, "who's there?")]) + alice #$> ("/_get chat *1 count=1", chat, [(1, "who's there?")]) + alice #$> ("/_get chat *1 after=2 count=10", chat, [(1, "knock-knock"), (1, "who's there?")]) + alice #$> ("/_get chat *1 after=2 count=2", chat, [(1, "knock-knock"), (1, "who's there?")]) + alice #$> ("/_get chat *1 after=1 count=2", chat, [(1, "memento mori"), (1, "knock-knock")]) + alice #$> ("/_get chat *1 before=3 count=10", chat, [(1, "hello world"), (1, "memento mori")]) + alice #$> ("/_get chat *1 before=3 count=2", chat, [(1, "hello world"), (1, "memento mori")]) + alice #$> ("/_get chat *1 before=4 count=2", chat, [(1, "memento mori"), (1, "knock-knock")]) - alice #$> ("/_get chat -1 count=10 search=k-k", chat, [(1, "knock-knock")]) + alice #$> ("/_get chat *1 count=10 search=k-k", chat, [(1, "knock-knock")]) testFiles :: FilePath -> IO () testFiles tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do @@ -118,15 +118,15 @@ testFiles tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do let source = "./tests/fixtures/test.jpg" let stored = files "test.jpg" copyFile source stored - alice ##> "/_create -1 json {\"filePath\": \"test.jpg\", \"msgContent\": {\"text\":\"hi myself\",\"type\":\"image\",\"image\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII=\"}}" - alice <# "- hi myself" - alice <# "- file 1 (test.jpg)" + alice ##> "/_create *1 json {\"filePath\": \"test.jpg\", \"msgContent\": {\"text\":\"hi myself\",\"type\":\"image\",\"image\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII=\"}}" + alice <# "* hi myself" + alice <# "* file 1 (test.jpg)" alice ##> "/tail" - alice <# "- hi myself" - alice <# "- file 1 (test.jpg)" + alice <# "* hi myself" + alice <# "* file 1 (test.jpg)" - alice ##> "/_get chat -1 count=100" + alice ##> "/_get chat *1 count=100" r <- chatF <$> getTermLine alice r `shouldBe` [((1, "hi myself"), Just "test.jpg")] @@ -136,15 +136,15 @@ testFiles tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do -- one more file let stored2 = files "another_test.jpg" copyFile source stored2 - alice ##> "/_create -1 json {\"filePath\": \"another_test.jpg\", \"msgContent\": {\"text\":\"\",\"type\":\"image\",\"image\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII=\"}}" - alice <# "- file 2 (another_test.jpg)" + alice ##> "/_create *1 json {\"filePath\": \"another_test.jpg\", \"msgContent\": {\"text\":\"\",\"type\":\"image\",\"image\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII=\"}}" + alice <# "* file 2 (another_test.jpg)" - alice ##> "/_delete item -1 2 internal" + alice ##> "/_delete item *1 2 internal" alice <## "message deleted" doesFileExist stored2 `shouldReturn` False doesFileExist stored `shouldReturn` True - alice ##> "/clear -" + alice ##> "/clear *" alice ##> "/fs 1" alice <## "chat db error: SEChatItemNotFoundByFileId {fileId = 1}" alice ##> "/tail" diff --git a/tests/ChatTests/Utils.hs b/tests/ChatTests/Utils.hs index 95134b8192..a7fd55ea49 100644 --- a/tests/ChatTests/Utils.hs +++ b/tests/ChatTests/Utils.hs @@ -289,10 +289,10 @@ cc <##.. ls = do unless prefix $ print ("expected to start from one of: " <> show ls, ", got: " <> l) prefix `shouldBe` True -(/-) :: HasCallStack => TestCC -> String -> IO () -cc /- note = do - cc `send` ("/- " <> note) - (dropTime <$> getTermLine cc) `shouldReturn` ("- " <> note) +(/*) :: HasCallStack => TestCC -> String -> IO () +cc /* note = do + cc `send` ("/* " <> note) + (dropTime <$> getTermLine cc) `shouldReturn` ("* " <> note) data ConsoleResponse = ConsoleString String