From 3340bea150cecfaa96e9068dcd0d118b61450090 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sat, 19 Mar 2022 07:42:54 +0000 Subject: [PATCH] core: api to remove profile image (#448) --- src/Simplex/Chat.hs | 5 +++-- src/Simplex/Chat/Controller.hs | 2 +- tests/ChatTests.hs | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 66fac0bdd..ba228f7d1 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -436,7 +436,7 @@ processChatCommand = \case let p = (profile :: Profile) {displayName = displayName, fullName = fullName} updateProfile user p UpdateProfileImage image -> withUser $ \user@User {profile} -> do - let p = (profile :: Profile) {image = Just image} + let p = (profile :: Profile) {image} updateProfile user p QuitChat -> liftIO exitSuccess ShowVersion -> pure $ CRVersionInfo versionNumber @@ -1559,7 +1559,8 @@ chatCommandP = <|> ("/reject @" <|> "/reject " <|> "/rc @" <|> "/rc ") *> (RejectContact <$> displayName) <|> ("/markdown" <|> "/m") $> ChatHelp HSMarkdown <|> ("/welcome" <|> "/w") $> Welcome - <|> "/profile_image " *> (UpdateProfileImage . ProfileImage <$> imageP) + <|> "/profile_image " *> (UpdateProfileImage . Just . ProfileImage <$> imageP) + <|> "/profile_image" $> UpdateProfileImage Nothing <|> ("/profile " <|> "/p ") *> (uncurry UpdateProfile <$> userNames) <|> ("/profile" <|> "/p") $> ShowProfile <|> ("/quit" <|> "/q" <|> "/exit") $> QuitChat diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index bb61324e2..69bc95e44 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -131,7 +131,7 @@ data ChatCommand | FileStatus FileTransferId | ShowProfile | UpdateProfile ContactName Text - | UpdateProfileImage ProfileImage + | UpdateProfileImage (Maybe ProfileImage) | QuitChat | ShowVersion deriving (Show) diff --git a/tests/ChatTests.hs b/tests/ChatTests.hs index 889bb8ec0..a3606b859 100644 --- a/tests/ChatTests.hs +++ b/tests/ChatTests.hs @@ -670,6 +670,8 @@ testUpdateProfileImage = -- Note we currently don't support removing profile image. alice ##> "/profile_image data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII=" alice <## "profile image updated" + alice ##> "/profile_image" + alice <## "profile image removed" (bob