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.
This commit is contained in:
Narasimha-sc
2026-08-20 16:47:13 +00:00
parent cb4d5e0a3b
commit 57b4eeb7ee
+4 -3
View File
@@ -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)