[MM-21464] api4/channel: add ability to force move channel by removing non-members (#14887)
* api4/channel: add ability to force move channel by removing non-members * app/channel: add log to move channel for non taget team members * app/channel: add tets for remove non-team members for channel * Update api4/channel_test.go Co-authored-by: Eli Yukelzon <reflog@gmail.com> Co-authored-by: Eli Yukelzon <reflog@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b916bae0f7
Коммит
bf664997a7
@@ -177,6 +177,44 @@ func TestMoveChannel(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestRemoveUsersFromChannelNotMemberOfTeam(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
team := th.CreateTeam()
|
||||
team2 := th.CreateTeam()
|
||||
channel1 := th.CreateChannel(team)
|
||||
defer func() {
|
||||
th.App.PermanentDeleteChannel(channel1)
|
||||
th.App.PermanentDeleteTeam(team)
|
||||
th.App.PermanentDeleteTeam(team2)
|
||||
}()
|
||||
|
||||
_, err := th.App.AddUserToTeam(team.Id, th.BasicUser.Id, "")
|
||||
require.Nil(t, err)
|
||||
_, err = th.App.AddUserToTeam(team2.Id, th.BasicUser.Id, "")
|
||||
require.Nil(t, err)
|
||||
_, err = th.App.AddUserToTeam(team.Id, th.BasicUser2.Id, "")
|
||||
require.Nil(t, err)
|
||||
|
||||
_, err = th.App.AddUserToChannel(th.BasicUser, channel1)
|
||||
require.Nil(t, err)
|
||||
_, err = th.App.AddUserToChannel(th.BasicUser2, channel1)
|
||||
require.Nil(t, err)
|
||||
|
||||
err = th.App.RemoveUsersFromChannelNotMemberOfTeam(th.SystemAdminUser, channel1, team2)
|
||||
require.Nil(t, err)
|
||||
|
||||
channelMembers, err := th.App.GetChannelMembersPage(channel1.Id, 0, 10000000)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, *channelMembers, 1)
|
||||
members := make([]model.ChannelMember, len(*channelMembers))
|
||||
for i, m := range *channelMembers {
|
||||
members[i] = m
|
||||
}
|
||||
require.Equal(t, members[0].UserId, th.BasicUser.Id)
|
||||
}
|
||||
|
||||
func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordTownSquare(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user