mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-23 21:33:47 +00:00
core: do not accept contact request that was already accepted
This commit is contained in:
1 parent
b414d7579a
commit
a378626a5a
2 files changed
+23
No files matched your search
@@ -914,6 +914,10 @@ acceptContactRequest nm user@User {userId} UserContactRequest {agentInvitationId
|
||||
forM_ xContactId $ \xcId -> setContactAcceptedXContactId db ct xcId
|
||||
createAcceptedContactConn db user userContactLinkId_ contactId connId chatV cReqChatVRange pqSup' incognitoProfile subMode currentTs
|
||||
pure (ct {activeConn = Just conn} :: Contact, conn, incognitoProfile)
|
||||
-- contact connection in any status other than prepared is created when the request is accepted
|
||||
-- (see createAcceptedContactConn), so the request was already accepted -
|
||||
-- accepting it again would fail in the agent, as the invitation is already used.
|
||||
Just Connection {connStatus} | connStatus /= ConnPrepared -> throwCmdError "contact request already accepted"
|
||||
Just conn@Connection {customUserProfileId} -> do
|
||||
incognitoProfile <- forM customUserProfileId $ \pId -> withFastStore $ \db -> getProfileById db userId pId
|
||||
pure (ct, conn, ExistingIncognito <$> incognitoProfile)
|
||||
|
||||
@@ -61,6 +61,7 @@ chatProfileTests = do
|
||||
it "supporter badge sent to contact connecting via address" testUserBadgeContactAddress
|
||||
describe "user contact link" $ do
|
||||
it "create and connect via contact link" testUserContactLink
|
||||
it "accepting contact request twice fails" testAcceptContactRequestTwice
|
||||
it "create address on specified server" testCreateAddressOnServer
|
||||
it "retry connecting via contact link" testRetryConnectingViaContactLink
|
||||
it "add contact link to profile" testProfileLink
|
||||
@@ -644,6 +645,24 @@ testUserContactLink =
|
||||
alice @@@ [("@cath", lastChatFeature), ("@bob", "hey")]
|
||||
alice <##> cath
|
||||
|
||||
testAcceptContactRequestTwice :: HasCallStack => TestParams -> IO ()
|
||||
testAcceptContactRequestTwice =
|
||||
testChat2 aliceProfile bobProfile $
|
||||
\alice bob -> do
|
||||
alice ##> "/ad"
|
||||
cLink <- getContactLink alice True
|
||||
bob ##> ("/c " <> cLink)
|
||||
alice <#? bob
|
||||
alice ##> "/ac bob"
|
||||
alice <## "bob (Bob): accepting contact request, you can send messages to contact"
|
||||
concurrently_
|
||||
(bob <## "alice (Alice): contact is connected")
|
||||
(alice <## "bob (Bob): contact is connected")
|
||||
-- the request is not deleted when accepted, accepting it again fails without using the invitation
|
||||
alice ##> "/_accept 1"
|
||||
alice <## "bad chat command: contact request already accepted"
|
||||
alice <##> bob
|
||||
|
||||
testCreateAddressOnServer :: HasCallStack => TestParams -> IO ()
|
||||
testCreateAddressOnServer ps = testChat aliceProfile test ps
|
||||
where
|
||||
|
||||
Reference in new issue
Block a user