diff options
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/command.go')
-rw-r--r-- | vendor/github.com/mattermost/platform/model/command.go | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/vendor/github.com/mattermost/platform/model/command.go b/vendor/github.com/mattermost/platform/model/command.go index 47378bbe..69da41c1 100644 --- a/vendor/github.com/mattermost/platform/model/command.go +++ b/vendor/github.com/mattermost/platform/model/command.go @@ -6,6 +6,7 @@ package model import ( "encoding/json" "io" + "net/http" "strings" ) @@ -79,51 +80,51 @@ func CommandListFromJson(data io.Reader) []*Command { func (o *Command) IsValid() *AppError { if len(o.Id) != 26 { - return NewLocAppError("Command.IsValid", "model.command.is_valid.id.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.id.app_error", nil, "", http.StatusBadRequest) } if len(o.Token) != 26 { - return NewLocAppError("Command.IsValid", "model.command.is_valid.token.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.token.app_error", nil, "", http.StatusBadRequest) } if o.CreateAt == 0 { - return NewLocAppError("Command.IsValid", "model.command.is_valid.create_at.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.create_at.app_error", nil, "", http.StatusBadRequest) } if o.UpdateAt == 0 { - return NewLocAppError("Command.IsValid", "model.command.is_valid.update_at.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.update_at.app_error", nil, "", http.StatusBadRequest) } if len(o.CreatorId) != 26 { - return NewLocAppError("Command.IsValid", "model.command.is_valid.user_id.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.user_id.app_error", nil, "", http.StatusBadRequest) } if len(o.TeamId) != 26 { - return NewLocAppError("Command.IsValid", "model.command.is_valid.team_id.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.team_id.app_error", nil, "", http.StatusBadRequest) } if len(o.Trigger) < MIN_TRIGGER_LENGTH || len(o.Trigger) > MAX_TRIGGER_LENGTH || strings.Index(o.Trigger, "/") == 0 || strings.Contains(o.Trigger, " ") { - return NewLocAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "", http.StatusBadRequest) } if len(o.URL) == 0 || len(o.URL) > 1024 { - return NewLocAppError("Command.IsValid", "model.command.is_valid.url.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.url.app_error", nil, "", http.StatusBadRequest) } if !IsValidHttpUrl(o.URL) { - return NewLocAppError("Command.IsValid", "model.command.is_valid.url_http.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.url_http.app_error", nil, "", http.StatusBadRequest) } if !(o.Method == COMMAND_METHOD_GET || o.Method == COMMAND_METHOD_POST) { - return NewLocAppError("Command.IsValid", "model.command.is_valid.method.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.method.app_error", nil, "", http.StatusBadRequest) } if len(o.DisplayName) > 64 { - return NewLocAppError("Command.IsValid", "model.command.is_valid.display_name.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.display_name.app_error", nil, "", http.StatusBadRequest) } if len(o.Description) > 128 { - return NewLocAppError("Command.IsValid", "model.command.is_valid.description.app_error", nil, "") + return NewAppError("Command.IsValid", "model.command.is_valid.description.app_error", nil, "", http.StatusBadRequest) } return nil |