Added missed license check for channel banner in patch channel API (#30445)
* Added missed license check for channel banner in patch channel API * Extractced permission check function
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4fc77ce368
Коммит
84fa496c69
@@ -377,9 +377,12 @@ func patchChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if patch.BannerInfo != nil && (originalOldChannel.Type != model.ChannelTypeOpen && originalOldChannel.Type != model.ChannelTypePrivate) {
|
||||
c.Err = model.NewAppError("patchChannel", "api.channel.update_channel.banner_info.channel_type.not_allowed", nil, "", http.StatusBadRequest)
|
||||
return
|
||||
if patch.BannerInfo != nil {
|
||||
if channelBannerAppErr := canEditChannelBanner(c.App.License(), originalOldChannel); channelBannerAppErr != nil {
|
||||
channelBannerAppErr.Where = "patchChannel"
|
||||
c.Err = channelBannerAppErr
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
rchannel, appErr := c.App.PatchChannel(c.AppContext, oldChannel, patch, c.AppContext.Session().UserId)
|
||||
@@ -2439,3 +2442,15 @@ func convertGroupMessageToChannel(c *Context, w http.ResponseWriter, r *http.Req
|
||||
c.Logger.Warn("Error while writing response from convertGroupMessageToChannel", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
func canEditChannelBanner(license *model.License, originalChannel *model.Channel) *model.AppError {
|
||||
if license == nil || !license.IsE20OrEnterprise() {
|
||||
return model.NewAppError("", "license_error.feature_unavailable", nil, "feature is not available for the current license", http.StatusForbidden)
|
||||
}
|
||||
|
||||
if originalChannel.Type != model.ChannelTypeOpen && originalChannel.Type != model.ChannelTypePrivate {
|
||||
return model.NewAppError("", "api.channel.update_channel.banner_info.channel_type.not_allowed", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user