mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-22 03:40:17 +00:00
chat: CESimplexNameNotFound for name lookup misses
connectPlanName now distinguishes "name not found" from "connection
link is invalid". CEInvalidConnReq's message ("Connection link is
invalid, possibly it was created in a previous version") was
misleading when a user typed @alice.simplex against a database that
simply has no contact by that name.
The two "missing prepared link" cases stay on CEInvalidConnReq —
the lookup found a row but the stored link is unusable, which is
closer to the existing semantics. The two truly-missing cases
(no contact found / no group found) move to CESimplexNameNotFound,
which also surfaces the name back to the client for a precise UX.
This commit is contained in:
@@ -1368,6 +1368,7 @@ data ChatErrorType
|
||||
| CEChatNotStopped
|
||||
| CEChatStoreChanged
|
||||
| CEInvalidConnReq
|
||||
| CESimplexNameNotFound {simplexName :: SimplexNameInfo}
|
||||
| CEUnsupportedConnReq
|
||||
| CEInvalidChatMessage {connection :: Connection, msgMeta :: Maybe MsgMetaJSON, messageData :: Text, message :: String}
|
||||
| CEConnReqMessageProhibited
|
||||
|
||||
@@ -4179,7 +4179,7 @@ processChatCommand vr nm = \case
|
||||
Just PreparedContact {connLinkToConnect} -> pure (connLinkToConnect, CPContactAddress (CAPKnown ct))
|
||||
Nothing -> throwChatError CEInvalidConnReq
|
||||
Nothing -> case nameType of
|
||||
NTContact -> throwChatError CEInvalidConnReq
|
||||
NTContact -> throwChatError $ CESimplexNameNotFound ni
|
||||
NTPublicGroup -> do
|
||||
g_ <- withFastStore $ \db -> getGroupInfoBySimplexName db vr user ni
|
||||
case g_ of
|
||||
@@ -4187,7 +4187,7 @@ processChatCommand vr nm = \case
|
||||
Just PreparedGroup {connLinkToConnect = ccLink} ->
|
||||
pure (ACCL SCMContact ccLink, CPGroupLink (GLPKnown g (BoolDef False) Nothing (ListDef [])))
|
||||
Nothing -> throwChatError CEInvalidConnReq
|
||||
Nothing -> throwChatError CEInvalidConnReq
|
||||
Nothing -> throwChatError $ CESimplexNameNotFound ni
|
||||
connectWithPlan :: User -> IncognitoEnabled -> ACreatedConnLink -> ConnectionPlan -> CM ChatResponse
|
||||
connectWithPlan user@User {userId} incognito ccLink plan
|
||||
| connectionPlanProceed plan = do
|
||||
|
||||
@@ -2625,6 +2625,7 @@ viewChatError isCmd logLevel testView = \case
|
||||
CEChatNotStopped -> ["error: chat not stopped"]
|
||||
CEChatStoreChanged -> ["error: chat store changed, please restart chat"]
|
||||
CEInvalidConnReq -> viewInvalidConnReq
|
||||
CESimplexNameNotFound ni -> ["no contact or group with simplex name " <> plain (T.unpack (shortNameInfoStr ni))]
|
||||
CEUnsupportedConnReq -> [ "", "Connection link is not supported by the your app version, please ugrade it.", plain updateStr]
|
||||
CEInvalidChatMessage Connection {connId} msgMeta_ msg e ->
|
||||
[ plain $
|
||||
|
||||
Reference in New Issue
Block a user