diff --git a/apps/ios/Shared/Model/ChatModel.swift b/apps/ios/Shared/Model/ChatModel.swift index bff6b8d01d..2d8aacb26f 100644 --- a/apps/ios/Shared/Model/ChatModel.swift +++ b/apps/ios/Shared/Model/ChatModel.swift @@ -383,8 +383,6 @@ final class ChatModel: ObservableObject { // list of chat "previews" @Published private(set) var chats: [Chat] = [] @Published var deletedChats: Set = [] - // ids of contact requests being accepted and of groups being joined, - // to not offer accepting the same invitation from another view @Published var acceptingContactRequests: Set = [] @Published var joiningGroups: Set = [] // current chat diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt index cafc7ea616..ba09b0365f 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt @@ -122,8 +122,7 @@ object ChatModel { val incompleteInitializedDbRemoved = mutableStateOf(false) // map of connections network statuses, key is agent connection id val switchingUsersAndHosts = mutableStateOf(false) - // ids of contact requests being accepted and of groups being joined, - // to not offer accepting the same invitation from another view + // ids of contact requests being accepted, to not offer accepting the same request from another view val acceptingContactRequests = mutableStateListOf() val joiningGroups = mutableStateListOf() diff --git a/src/Simplex/Chat/Library/Commands.hs b/src/Simplex/Chat/Library/Commands.hs index 238ffe7c01..9e809802f4 100644 --- a/src/Simplex/Chat/Library/Commands.hs +++ b/src/Simplex/Chat/Library/Commands.hs @@ -3771,9 +3771,6 @@ processChatCommand cxt nm = \case Nothing -> connect' groupLinkId Nothing (Just $ Just gInfo) Just conn@Connection {connStatus, xContactId} -> case connStatus of ConnPrepared -> joinPreparedConn' xContactId conn (Just $ Just gInfo) - -- the connection is only advanced past ConnPrepared once the join succeeded (see joinContact), - -- so retrying a join that failed reuses it above, and reaching here means it already joined - - -- connecting again would create a second connection for the same member. _ -> throwCmdError "group is already being joined" Nothing -> withFastStore' (\db -> getConnReqContactXContactId db cxt user cReqHash1 cReqHash2) >>= \case diff --git a/src/Simplex/Chat/Library/Internal.hs b/src/Simplex/Chat/Library/Internal.hs index 843bbd6dfb..22601ed656 100644 --- a/src/Simplex/Chat/Library/Internal.hs +++ b/src/Simplex/Chat/Library/Internal.hs @@ -921,8 +921,6 @@ 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) - -- the agent marks the invitation accepted only once joining succeeded (see acceptContact'), - -- so not finding it is what tells an accepted request from an accept that failed and can be retried `catchAllErrors` \case ChatErrorAgent {agentError = CMD PROHIBITED _} -> throwCmdError "contact request already accepted" e -> throwError e diff --git a/src/Simplex/Chat/Store/Groups.hs b/src/Simplex/Chat/Store/Groups.hs index a45a814436..ac1d0b904c 100644 --- a/src/Simplex/Chat/Store/Groups.hs +++ b/src/Simplex/Chat/Store/Groups.hs @@ -3505,8 +3505,6 @@ createNewUnknownGroupMember db cxt user@User {userId, userContactId} GroupInfo { where VersionRange minV maxV = vr cxt --- Re-use owner member record on retry: owners are created before the relay loop, --- which is what fails when the network does (see getCreateRelayForMember) getCreateLinkOwnerMember :: DB.Connection -> StoreCxt -> User -> GroupInfo -> Maybe ContactId -> MemberId -> C.PublicKeyEd25519 -> ExceptT StoreError IO GroupMember getCreateLinkOwnerMember db cxt user gInfo contactId_ memberId ownerKey = liftIO (runExceptT $ getGroupMemberByMemberId db cxt user gInfo memberId) >>= \case diff --git a/tests/ChatTests/Groups.hs b/tests/ChatTests/Groups.hs index 7702caec9d..8770522322 100644 --- a/tests/ChatTests/Groups.hs +++ b/tests/ChatTests/Groups.hs @@ -8908,8 +8908,6 @@ testChannelConnectTwice ps = withNewTestChat ps "cath" cathProfile $ \cath -> do (shortLink, fullLink) <- prepareChannel1Relay "team" alice bob memberJoinChannel "team" [bob] [alice] shortLink fullLink cath - -- connecting again reuses the owner members the first connection created, - -- and is rejected before it can create a second connection to the relay cath ##> "/_connect group #1" cath <## "bad chat command: group is already being joined" alice #> "#team hi" diff --git a/tests/ChatTests/Profiles.hs b/tests/ChatTests/Profiles.hs index 21673b0a53..44e7af240d 100644 --- a/tests/ChatTests/Profiles.hs +++ b/tests/ChatTests/Profiles.hs @@ -3783,7 +3783,6 @@ testShortLinkPrepareGroupConnectTwice = testChat3 aliceProfile bobProfile cathPr cath <## "#team: alice added bob (Bob) to the group (connecting...)" cath <## "#team: new member bob is connected" ] - -- connecting again is rejected before it can create a second connection to the host member bob ##> "/_connect group #1" bob <## "bad chat command: group is already being joined" alice #> "#team 1"