show "upgrade" message on invalid connection request (#164)

This commit is contained in:
Evgeny Poberezkin
2021-12-24 11:12:08 +00:00
committed by GitHub
parent e7f9e5a834
commit 29b683329d
2 changed files with 15 additions and 4 deletions
+5 -4
View File
@@ -72,7 +72,7 @@ data ChatCommand
| MarkdownHelp
| Welcome
| AddContact
| Connect AConnectionRequest
| Connect (Maybe AConnectionRequest)
| ConnectAdmin
| SendAdminWelcome ContactName
| DeleteContact ContactName
@@ -203,8 +203,9 @@ processChatCommand user@User {userId, profile} = \case
(connId, cReq) <- withAgent (`createConnection` SCMInvitation)
withStore $ \st -> createDirectConnection st userId connId
showInvitation cReq
Connect (ACR SCMInvitation cReq) -> connect cReq (XInfo profile) >> showSentConfirmation
Connect (ACR SCMContact cReq) -> connect cReq (XContact profile Nothing) >> showSentInvitation
Connect (Just (ACR SCMInvitation cReq)) -> connect cReq (XInfo profile) >> showSentConfirmation
Connect (Just (ACR SCMContact cReq)) -> connect cReq (XContact profile Nothing) >> showSentInvitation
Connect Nothing -> showInvalidConnReq
ConnectAdmin -> connect adminContactReq (XContact profile Nothing) >> showSentInvitation
SendAdminWelcome cName -> forM_ adminWelcomeMessages $ sendMessageCmd cName
DeleteContact cName ->
@@ -1187,7 +1188,7 @@ chatCommandP =
<|> ("/groups" <|> "/gs") $> ListGroups
<|> A.char '#' *> (SendGroupMessage <$> displayName <* A.space <*> A.takeByteString)
<|> ("/contacts" <|> "/cs") $> ListContacts
<|> ("/connect " <|> "/c ") *> (Connect <$> connReqP)
<|> ("/connect " <|> "/c ") *> (Connect <$> ((Just <$> connReqP) <|> A.takeByteString $> Nothing))
<|> ("/connect" <|> "/c") $> AddContact
<|> ("/delete @" <|> "/delete " <|> "/d @" <|> "/d ") *> (DeleteContact <$> displayName)
<|> A.char '@' *> (SendMessage <$> displayName <*> (A.space *> A.takeByteString))
+10
View File
@@ -10,6 +10,7 @@ module Simplex.Chat.View
showInvitation,
showSentConfirmation,
showSentInvitation,
showInvalidConnReq,
showChatError,
showContactDeleted,
showContactGroups,
@@ -113,6 +114,15 @@ showSentConfirmation = printToView ["confirmation sent!"]
showSentInvitation :: ChatReader m => m ()
showSentInvitation = printToView ["connection request sent!"]
showInvalidConnReq :: ChatReader m => m ()
showInvalidConnReq =
printToView
[ "Connection link is invalid!",
"Possibly, it was created in a newer version (to check version: " <> highlight' "/v" <> ")",
"To upgrade (Linux/Mac):",
"curl -o- https://raw.githubusercontent.com/simplex-chat/simplex-chat/master/install.sh | bash"
]
showChatError :: ChatReader m => ChatError -> m ()
showChatError = printToView . chatError