diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index f87b62ef50..699f66f0e9 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -296,7 +296,7 @@ processChatCommand user@User {userId, profile} = \case let s = memberStatus membership canDelete = memberRole membership == GROwner - || (s == GSMemRemoved || s == GSMemLeft || s == GSMemGroupDeleted) + || (s == GSMemRemoved || s == GSMemLeft || s == GSMemGroupDeleted || s == GSMemInvited) unless canDelete $ chatError CEGroupUserRole when (memberActive membership) $ sendGroupMessage members XGrpDel mapM_ deleteMemberConnection members diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 6036c68650..3367d130dd 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -716,7 +716,7 @@ chatError = \case CEGroupContactRole c -> ["contact " <> ttyContact c <> " has insufficient permissions for this group action"] CEGroupNotJoined g -> ["you did not join this group, use " <> highlight ("/join #" <> g)] CEGroupMemberNotActive -> ["you cannot invite other members yet, try later"] - CEGroupMemberUserRemoved -> ["you are no longer the member of the group"] + CEGroupMemberUserRemoved -> ["you are no longer a member of the group"] CEGroupMemberNotFound c -> ["contact " <> ttyContact c <> " is not a group member"] CEGroupInternal s -> ["chat group bug: " <> plain s] CEFileNotFound f -> ["file not found: " <> plain f] diff --git a/tests/ChatTests.hs b/tests/ChatTests.hs index 05cc7a2bf7..cb3ae88a61 100644 --- a/tests/ChatTests.hs +++ b/tests/ChatTests.hs @@ -37,6 +37,7 @@ chatTests = do it "add contacts, create group and send/receive messages" testGroup it "create and join group with 4 members" testGroup2 it "create and delete group" testGroupDelete + it "invitee delete group when in status invited" testGroupDeleteWhenInvited it "remove contact from group and add again" testGroupRemoveAdd describe "user profiles" $ it "update user profiles and notify contacts" testUpdateProfile @@ -166,7 +167,7 @@ testGroup = (bob <# "#team alice> hello") (cath "#team hello" - cath <## "you are no longer the member of the group" + cath <## "you are no longer a member of the group" bob <##> cath testGroup2 :: IO () @@ -291,7 +292,7 @@ testGroup2 = (dan "#club how is it going?" - dan <## "you are no longer the member of the group" + dan <## "you are no longer a member of the group" dan <##> cath dan <##> alice -- member leaves @@ -312,7 +313,7 @@ testGroup2 = (alice <# "#club cath> hey") (bob "#club how is it going?" - bob <## "you are no longer the member of the group" + bob <## "you are no longer a member of the group" bob <##> cath bob <##> alice @@ -334,7 +335,38 @@ testGroupDelete = bob ##> "/d #team" bob <## "#team: you deleted the group" cath #> "#team hi" - cath <## "you are no longer the member of the group" + cath <## "you are no longer a member of the group" + +testGroupDeleteWhenInvited :: IO () +testGroupDeleteWhenInvited = + testChat2 aliceProfile bobProfile $ + \alice bob -> do + connectUsers alice bob + alice ##> "/g team" + alice <## "group #team is created" + alice <## "use /a team to add members" + alice ##> "/a team bob" + concurrentlyN_ + [ alice <## "invitation to join the group #team sent to bob", + do + bob <## "#team: alice invites you to join the group as admin" + bob <## "use /j team to accept" + ] + bob ##> "/d #team" + bob <## "#team: you deleted the group" + -- alice shouldn't receive notification that bob deleted group, + -- but she should be able to remove and re-add bob + alice ##> "/a team bob" + alice <## "contact bob is already in the group" + alice ##> "/rm team bob" + alice <## "#team: you removed bob from the group" + alice ##> "/a team bob" + concurrentlyN_ + [ alice <## "invitation to join the group #team sent to bob", + do + bob <## "#team: alice invites you to join the group as admin" + bob <## "use /j team to accept" + ] testGroupRemoveAdd :: IO () testGroupRemoveAdd =