[MM-18391] Removing convert channel endpoint (#18015)

* removing convert endpoint

* fixing translations

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Этот коммит содержится в:
Ben Cooke
2021-08-16 09:10:31 -07:00
коммит произвёл GitHub
родитель f43aa7d925
Коммит a7f5512ff3
4 изменённых файлов: 0 добавлений и 148 удалений

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

@@ -48,7 +48,6 @@ func (api *API) InitChannel() {
api.BaseRoutes.Channel.Handle("", api.ApiSessionRequired(getChannel)).Methods("GET")
api.BaseRoutes.Channel.Handle("", api.ApiSessionRequired(updateChannel)).Methods("PUT")
api.BaseRoutes.Channel.Handle("/patch", api.ApiSessionRequired(patchChannel)).Methods("PUT")
api.BaseRoutes.Channel.Handle("/convert", api.ApiSessionRequired(convertChannelToPrivate)).Methods("POST")
api.BaseRoutes.Channel.Handle("/privacy", api.ApiSessionRequired(updateChannelPrivacy)).Methods("PUT")
api.BaseRoutes.Channel.Handle("/restore", api.ApiSessionRequired(restoreChannel)).Methods("POST")
api.BaseRoutes.Channel.Handle("", api.ApiSessionRequired(deleteChannel)).Methods("DELETE")
@@ -228,60 +227,6 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
func convertChannelToPrivate(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireChannelId()
if c.Err != nil {
return
}
oldPublicChannel, err := c.App.GetChannel(c.Params.ChannelId)
if err != nil {
c.Err = err
return
}
auditRec := c.MakeAuditRecord("convertChannelToPrivate", audit.Fail)
defer c.LogAuditRec(auditRec)
auditRec.AddMeta("channel", oldPublicChannel)
if !c.App.SessionHasPermissionToChannel(*c.AppContext.Session(), c.Params.ChannelId, model.PermissionConvertPublicChannelToPrivate) {
c.SetPermissionError(model.PermissionConvertPublicChannelToPrivate)
return
}
if oldPublicChannel.Type == model.ChannelTypePrivate {
c.Err = model.NewAppError("convertChannelToPrivate", "api.channel.convert_channel_to_private.private_channel_error", nil, "", http.StatusBadRequest)
return
}
if oldPublicChannel.Name == model.DefaultChannelName {
c.Err = model.NewAppError("convertChannelToPrivate", "api.channel.convert_channel_to_private.default_channel_error", nil, "", http.StatusBadRequest)
return
}
user, err := c.App.GetUser(c.AppContext.Session().UserId)
if err != nil {
c.Err = err
return
}
auditRec.AddMeta("user", user)
oldPublicChannel.Type = model.ChannelTypePrivate
rchannel, err := c.App.UpdateChannelPrivacy(c.AppContext, oldPublicChannel, user)
if err != nil {
c.Err = err
return
}
auditRec.Success()
c.LogAudit("name=" + rchannel.Name)
if err := json.NewEncoder(w).Encode(rchannel); err != nil {
mlog.Warn("Error while writing response", mlog.Err(err))
}
}
func updateChannelPrivacy(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireChannelId()
if c.Err != nil {