ui: allow to block removed member or member that left (#6440)

This commit is contained in:
spaced4ndy
2025-11-14 09:00:58 +00:00
committed by GitHub
parent f67dfcce5f
commit 70e23a04ce
3 changed files with 36 additions and 2 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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