mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-03-30 16:25:57 +00:00
ui: allow to block removed member or member that left (#6440)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user