feat: add new CommunityMemberState - CommunityMemberBanWithAllMessagesDelete (#4941)
This commit is contained in:
parent
f0d6a4f64f
commit
a1033f466a
|
@ -129,6 +129,7 @@ const (
|
|||
CommunityMemberBanPending
|
||||
CommunityMemberUnbanPending
|
||||
CommunityMemberKickPending
|
||||
CommunityMemberBanWithAllMessagesDelete
|
||||
)
|
||||
|
||||
func (o *Community) MarshalPublicAPIJSON() ([]byte, error) {
|
||||
|
@ -1643,8 +1644,12 @@ func (o *Community) PendingAndBannedMembers() map[string]CommunityMemberState {
|
|||
result := make(map[string]CommunityMemberState)
|
||||
|
||||
if o.config.CommunityDescription.BannedMembers != nil {
|
||||
for bannedMemberID := range o.config.CommunityDescription.BannedMembers {
|
||||
result[bannedMemberID] = CommunityMemberBanned
|
||||
for bannedMemberID, banInfo := range o.config.CommunityDescription.BannedMembers {
|
||||
state := CommunityMemberBanned
|
||||
if banInfo.DeleteAllMessages {
|
||||
state = CommunityMemberBanWithAllMessagesDelete
|
||||
}
|
||||
result[bannedMemberID] = state
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -711,7 +711,12 @@ func banMember(base CommunityEventsTestsInterface, banRequest *requests.BanUserF
|
|||
return errors.New("alice was not added to the banned list")
|
||||
}
|
||||
|
||||
if modifiedCommmunity.PendingAndBannedMembers()[bannedPK] != communities.CommunityMemberBanned {
|
||||
expectedState := communities.CommunityMemberBanned
|
||||
if banRequest.DeleteAllMessages {
|
||||
expectedState = communities.CommunityMemberBanWithAllMessagesDelete
|
||||
}
|
||||
|
||||
if modifiedCommmunity.PendingAndBannedMembers()[bannedPK] != expectedState {
|
||||
return errors.New("alice should be in the pending state")
|
||||
}
|
||||
|
||||
|
|
|
@ -2359,12 +2359,14 @@ func (s *MessengerCommunitiesSuite) TestBanUser() {
|
|||
s.Require().False(community.HasMember(&s.alice.identity.PublicKey))
|
||||
s.Require().True(community.IsBanned(&s.alice.identity.PublicKey))
|
||||
s.Require().Len(community.PendingAndBannedMembers(), 1)
|
||||
s.Require().Equal(community.PendingAndBannedMembers()[s.alice.IdentityPublicKeyString()], communities.CommunityMemberBanned)
|
||||
|
||||
response, err = WaitOnMessengerResponse(
|
||||
s.alice,
|
||||
func(r *MessengerResponse) bool {
|
||||
return len(r.Communities()) == 1 &&
|
||||
len(r.Communities()[0].PendingAndBannedMembers()) == 1 &&
|
||||
community.PendingAndBannedMembers()[s.alice.IdentityPublicKeyString()] == communities.CommunityMemberBanned &&
|
||||
r.Communities()[0].IsBanned(&s.alice.identity.PublicKey) &&
|
||||
len(r.ActivityCenterNotifications()) == 1 &&
|
||||
!r.ActivityCenterState().HasSeen &&
|
||||
|
@ -4157,6 +4159,7 @@ func (s *MessengerCommunitiesSuite) TestBanUserAndDeleteAllUserMessages() {
|
|||
s.Require().False(community.HasMember(&s.alice.identity.PublicKey))
|
||||
s.Require().True(community.IsBanned(&s.alice.identity.PublicKey))
|
||||
s.Require().Len(community.PendingAndBannedMembers(), 1)
|
||||
s.Require().Equal(community.PendingAndBannedMembers()[s.alice.IdentityPublicKeyString()], communities.CommunityMemberBanWithAllMessagesDelete)
|
||||
|
||||
response, err = WaitOnMessengerResponse(
|
||||
s.alice,
|
||||
|
@ -4179,6 +4182,7 @@ func (s *MessengerCommunitiesSuite) TestBanUserAndDeleteAllUserMessages() {
|
|||
s.Require().False(community.HasMember(&s.alice.identity.PublicKey))
|
||||
s.Require().True(community.IsBanned(&s.alice.identity.PublicKey))
|
||||
s.Require().Len(community.PendingAndBannedMembers(), 1)
|
||||
s.Require().Equal(community.PendingAndBannedMembers()[s.alice.IdentityPublicKeyString()], communities.CommunityMemberBanWithAllMessagesDelete)
|
||||
s.Require().False(community.Joined())
|
||||
s.Require().False(community.Spectated())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue