Gh 24291 api meesage unclear when parameters are incorrect (#26457)

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Ezekiel
2024-04-10 17:04:41 +08:00
коммит произвёл GitHub
родитель 1806ba2cc7
Коммит 9fee0393c3
4 изменённых файлов: 47 добавлений и 9 удалений

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

@@ -10,6 +10,7 @@ import (
"strings"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/i18n"
"github.com/mattermost/mattermost/server/public/shared/mlog"
"github.com/mattermost/mattermost/server/v8/channels/app"
"github.com/mattermost/mattermost/server/v8/channels/audit"
@@ -89,6 +90,16 @@ func createChannel(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if channel.TeamId == "" {
c.SetInvalidParamWithDetails("team_id", i18n.T("api.channel.create_channel.missing_team_id.error"))
return
}
if channel.DisplayName == "" {
c.SetInvalidParamWithDetails("display_name", i18n.T("api.channel.create_channel.missing_display_name.error"))
return
}
auditRec := c.MakeAuditRecord("createChannel", audit.Fail)
defer c.LogAuditRec(auditRec)
audit.AddEventParameterAuditable(auditRec, "channel", channel)