core: api to remove profile image (#448)

This commit is contained in:
Evgeny Poberezkin
2022-03-19 07:42:54 +00:00
committed by GitHub
parent 0e73697ea4
commit 3340bea150
3 changed files with 6 additions and 3 deletions

View File

@@ -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

View File

@@ -131,7 +131,7 @@ data ChatCommand
| FileStatus FileTransferId
| ShowProfile
| UpdateProfile ContactName Text
| UpdateProfileImage ProfileImage
| UpdateProfileImage (Maybe ProfileImage)
| QuitChat
| ShowVersion
deriving (Show)

View File

@@ -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 </)
testFileTransfer :: IO ()