From 29b683329d067fd415581ef2de492ce29e5687c0 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Fri, 24 Dec 2021 11:12:08 +0000 Subject: [PATCH] show "upgrade" message on invalid connection request (#164) --- src/Simplex/Chat.hs | 9 +++++---- src/Simplex/Chat/View.hs | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 7eddcf7ad1..d7a98c0974 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -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)) diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 80d5a1655c..6036c68650 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -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