mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-04 17:31:42 +00:00
chat: CESimplexNameUnprepared for found-but-no-link cases + member-removed filter
connectPlanName previously threw CEInvalidConnReq when a name lookup
hit a contact / group row whose preparedContact / preparedGroup was
NULL. The error message ("Connection link is invalid, possibly it was
created in a previous version") was wrong: the name resolved fine,
the device just has no link material to reconnect via (typical for a
contact created via the XInfo handler rather than the prepare path).
Introduce CESimplexNameUnprepared SimplexNameInfo for this case.
Also mirror the link-based path's gPlan (Commands.hs:4133) for groups
whose membership state is GSMemRemoved — return CESimplexNameNotFound
rather than GLPKnown for a removed-member group, since GLPKnown for
removed members would be inconsistent with how /_connect plan over a
short link handles the same situation.
This commit is contained in:
@@ -1369,6 +1369,7 @@ data ChatErrorType
|
||||
| CEChatStoreChanged
|
||||
| CEInvalidConnReq
|
||||
| CESimplexNameNotFound {simplexName :: SimplexNameInfo}
|
||||
| CESimplexNameUnprepared {simplexName :: SimplexNameInfo}
|
||||
| CEUnsupportedConnReq
|
||||
| CEInvalidChatMessage {connection :: Connection, msgMeta :: Maybe MsgMetaJSON, messageData :: Text, message :: String}
|
||||
| CEConnReqMessageProhibited
|
||||
|
||||
@@ -4181,15 +4181,20 @@ processChatCommand vr nm = \case
|
||||
case ct_ of
|
||||
Just ct -> case preparedContact ct of
|
||||
Just PreparedContact {connLinkToConnect} -> pure (connLinkToConnect, CPContactAddress (CAPKnown ct))
|
||||
Nothing -> throwChatError CEInvalidConnReq
|
||||
-- Row exists but carries no reconnect link (e.g. created via XInfo, not via prepare).
|
||||
-- The name resolves; the device just lacks the connection material to re-establish.
|
||||
Nothing -> throwChatError $ CESimplexNameUnprepared ni
|
||||
Nothing -> throwChatError $ CESimplexNameNotFound ni
|
||||
NTPublicGroup -> do
|
||||
g_ <- withFastStore $ \db -> getGroupInfoBySimplexName db vr user ni
|
||||
case g_ of
|
||||
-- Mirror gPlan at line ~4133 in the link-based path: a removed member is not a
|
||||
-- known-and-reconnectable group; treat as "not found" so the caller can try elsewhere.
|
||||
Just g | memberRemoved (membership g) -> throwChatError $ CESimplexNameNotFound ni
|
||||
Just g -> case preparedGroup g of
|
||||
Just PreparedGroup {connLinkToConnect = ccLink} ->
|
||||
pure (ACCL SCMContact ccLink, CPGroupLink (GLPKnown g (BoolDef False) Nothing (ListDef [])))
|
||||
Nothing -> throwChatError CEInvalidConnReq
|
||||
Nothing -> throwChatError $ CESimplexNameUnprepared ni
|
||||
Nothing -> throwChatError $ CESimplexNameNotFound ni
|
||||
connectWithPlan :: User -> IncognitoEnabled -> ACreatedConnLink -> ConnectionPlan -> CM ChatResponse
|
||||
connectWithPlan user@User {userId} incognito ccLink plan
|
||||
|
||||
@@ -2626,6 +2626,7 @@ viewChatError isCmd logLevel testView = \case
|
||||
CEChatStoreChanged -> ["error: chat store changed, please restart chat"]
|
||||
CEInvalidConnReq -> viewInvalidConnReq
|
||||
CESimplexNameNotFound ni -> ["no contact or group with simplex name " <> plain (T.unpack (shortNameInfoStr ni))]
|
||||
CESimplexNameUnprepared ni -> [plain (T.unpack (shortNameInfoStr ni)) <> " is a known contact/group but has no link to reconnect via"]
|
||||
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