From 43503a7ef15ee7a9034cb5e51046490d2f4d06b4 Mon Sep 17 00:00:00 2001 From: shum Date: Wed, 3 Jun 2026 19:20:34 +0000 Subject: [PATCH] chat: CESimplexNameNotFound for name lookup misses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/Simplex/Chat/Controller.hs | 1 + src/Simplex/Chat/Library/Commands.hs | 4 ++-- src/Simplex/Chat/View.hs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index 2145afbe1f..aa4f56a1a8 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -1368,6 +1368,7 @@ data ChatErrorType | CEChatNotStopped | CEChatStoreChanged | CEInvalidConnReq + | CESimplexNameNotFound {simplexName :: SimplexNameInfo} | CEUnsupportedConnReq | CEInvalidChatMessage {connection :: Connection, msgMeta :: Maybe MsgMetaJSON, messageData :: Text, message :: String} | CEConnReqMessageProhibited diff --git a/src/Simplex/Chat/Library/Commands.hs b/src/Simplex/Chat/Library/Commands.hs index 2c949a809c..71f013eb62 100644 --- a/src/Simplex/Chat/Library/Commands.hs +++ b/src/Simplex/Chat/Library/Commands.hs @@ -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 diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 58b4c0c078..8251cf1f93 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -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 $