mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-09 13:56:06 +00:00
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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user