diff --git a/apps/ios/SimpleXChat/ChatTypes.swift b/apps/ios/SimpleXChat/ChatTypes.swift index 1e9fbf15e6..469d01fbed 100644 --- a/apps/ios/SimpleXChat/ChatTypes.swift +++ b/apps/ios/SimpleXChat/ChatTypes.swift @@ -2647,7 +2647,7 @@ public struct GroupMember: Identifiable, Decodable, Hashable { public func canBlockForAll(groupInfo: GroupInfo) -> Bool { let userRole = groupInfo.membership.memberRole - return memberStatus != .memRemoved && memberStatus != .memLeft && memberRole < .moderator + return memberRole < .moderator && userRole >= .moderator && userRole >= memberRole && groupInfo.membership.memberActive && !memberPending } 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 debd0ec328..454dc90d12 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 @@ -2307,7 +2307,7 @@ data class GroupMember ( fun canBlockForAll(groupInfo: GroupInfo): Boolean { val userRole = groupInfo.membership.memberRole - return memberStatus != GroupMemberStatus.MemRemoved && memberStatus != GroupMemberStatus.MemLeft && memberRole < GroupMemberRole.Moderator + return memberRole < GroupMemberRole.Moderator && userRole >= GroupMemberRole.Moderator && userRole >= memberRole && groupInfo.membership.memberActive && !memberPending } diff --git a/tests/ChatTests/Groups.hs b/tests/ChatTests/Groups.hs index e9168ba469..da6d8789fb 100644 --- a/tests/ChatTests/Groups.hs +++ b/tests/ChatTests/Groups.hs @@ -198,6 +198,7 @@ chatGroupTests = do it "member was blocked before joining group" testBlockForAllBeforeJoining it "repeat block, unblock" testBlockForAllRepeat it "block multiple members" testBlockForAllMultipleMembers + it "block left/removed members" testBlockForAllLeftRemoved describe "group member inactivity" $ do it "mark member inactive on reaching quota" testGroupMemberInactive describe "group member reports" $ do @@ -6973,6 +6974,39 @@ testBlockForAllMultipleMembers = cath #> "#team 6" [alice, bob, dan] *<# "#team cath> 6" +testBlockForAllLeftRemoved :: HasCallStack => TestParams -> IO () +testBlockForAllLeftRemoved = + testChat4 aliceProfile bobProfile cathProfile danProfile $ + \alice bob cath dan -> do + createGroup4 "team" alice (bob, GRMember) (cath, GRMember) (dan, GRMember) + + cath ##> "/leave #team" + concurrentlyN_ + [ do + cath <## "#team: you left the group" + cath <## "use /d #team to delete the group", + alice <## "#team: cath left the group", + bob <## "#team: cath left the group", + dan <## "#team: cath left the group" + ] + + alice ##> "/rm team dan" + concurrentlyN_ + [ alice <## "#team: you removed dan from the group", + do + dan <## "#team: alice removed you from the group" + dan <## "use /d #team to delete the group", + bob <## "#team: alice removed dan from the group" + ] + + alice ##> "/block for all #team cath" + alice <## "#team: you blocked cath" + bob <## "#team: alice blocked cath" + + alice ##> "/block for all #team dan" + alice <## "#team: you blocked dan" + bob <## "#team: alice blocked dan" + testGroupMemberInactive :: HasCallStack => TestParams -> IO () testGroupMemberInactive ps = do withSmpServer' serverCfg' $ do