From 57b4eeb7ee124bee3707a29f777fa14a700c8fa1 Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Thu, 20 Aug 2026 16:47:13 +0000 Subject: [PATCH] core: match only the invitation error as an accepted request joinConnSrv raises CMD PROHIBITED too, on the same path, so matching the constructor alone reported a malformed connection as "contact request already accepted". Only SEInvitationNotFound carries that meaning, and storeError maps nothing else to CMD PROHIBITED, so match its context. catchError replaces catchAllErrors: withAgent surfaces agent errors as ChatError, and catchAllErrors would additionally convert exceptions this code did not catch before. --- src/Simplex/Chat/Library/Internal.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat/Library/Internal.hs b/src/Simplex/Chat/Library/Internal.hs index 22601ed656..9437556bb3 100644 --- a/src/Simplex/Chat/Library/Internal.hs +++ b/src/Simplex/Chat/Library/Internal.hs @@ -40,7 +40,7 @@ import Data.Foldable (foldr') import Data.Functor (($>)) import Data.Functor.Identity import Data.Int (Int64) -import Data.List (find, foldl', mapAccumL, partition) +import Data.List (find, foldl', isPrefixOf, mapAccumL, partition) import Data.List.NonEmpty (NonEmpty (..), (<|)) import qualified Data.List.NonEmpty as L import Data.Map.Strict (Map) @@ -921,8 +921,9 @@ acceptContactRequest nm user@User {userId} UserContactRequest {agentInvitationId dm <- encodeConnInfoPQ pqSup' chatV $ XInfo profileToSend sqSecured <- withAgent (\a -> acceptContact a nm (aUserId user) (aConnId conn) True invId dm pqSup' subMode) - `catchAllErrors` \case - ChatErrorAgent {agentError = CMD PROHIBITED _} -> throwCmdError "contact request already accepted" + `catchError` \case + ChatErrorAgent {agentError = CMD PROHIBITED errCxt} + | "SEInvitationNotFound" `isPrefixOf` errCxt -> throwCmdError "contact request already accepted" e -> throwError e pure (ct, conn, sqSecured)