adding check for name change and new tests (#18531)

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ben Cooke
2021-10-29 13:46:50 -04:00
коммит произвёл GitHub
родитель bf589c2995
Коммит 3181a3765d
2 изменённых файлов: 25 добавлений и 1 удалений

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

@@ -338,6 +338,13 @@ func patchChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if oldChannel.Name == model.DefaultChannelName {
if *patch.Name != "" && *patch.Name != oldChannel.Name {
c.Err = model.NewAppError("patchChannel", "api.channel.update_channel.tried.app_error", map[string]interface{}{"Channel": model.DefaultChannelName}, "", http.StatusBadRequest)
return
}
}
rchannel, appErr := c.App.PatchChannel(c.AppContext, oldChannel, patch, c.AppContext.Session().UserId)
if appErr != nil {
c.Err = appErr