[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>
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2020-07-16 11:26:19 +03:00
коммит произвёл GitHub
родитель b916bae0f7
Коммит bf664997a7
7 изменённых файлов: 111 добавлений и 11 удалений

Просмотреть файл

@@ -1810,6 +1810,12 @@ func moveChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
force, ok := props["force"].(bool)
if !ok {
c.SetInvalidParam("force")
return
}
team, err := c.App.GetTeam(teamId)
if err != nil {
c.Err = err
@@ -1845,6 +1851,14 @@ func moveChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if force {
err = c.App.RemoveUsersFromChannelNotMemberOfTeam(user, channel, team)
if err != nil {
c.Err = err
return
}
}
err = c.App.MoveChannel(team, channel, user)
if err != nil {
c.Err = err