diff options
author | Wim <wim@42.be> | 2017-03-25 21:04:10 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-03-25 21:04:10 +0100 |
commit | eacb1c1771cec126593f99f50aca4584236475fa (patch) | |
tree | 5ae7d8271c28e378d1d5ca2d0e1e243717a9bdbe /vendor/github.com/mattermost/platform/model/utils.go | |
parent | 07fd825349e8b7e86f8afb3843cb8e2c2afc7c74 (diff) | |
download | matterbridge-msglm-eacb1c1771cec126593f99f50aca4584236475fa.tar.gz matterbridge-msglm-eacb1c1771cec126593f99f50aca4584236475fa.tar.bz2 matterbridge-msglm-eacb1c1771cec126593f99f50aca4584236475fa.zip |
Update vendor (mattermost)
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/utils.go')
-rw-r--r-- | vendor/github.com/mattermost/platform/model/utils.go | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/vendor/github.com/mattermost/platform/model/utils.go b/vendor/github.com/mattermost/platform/model/utils.go index 0ce243fe..08809a47 100644 --- a/vendor/github.com/mattermost/platform/model/utils.go +++ b/vendor/github.com/mattermost/platform/model/utils.go @@ -34,14 +34,14 @@ type StringArray []string type EncryptStringMap map[string]string type AppError struct { - Id string `json:"id"` - Message string `json:"message"` // Message to be display to the end user without debugging information - DetailedError string `json:"detailed_error"` // Internal error string to help the developer - RequestId string `json:"request_id,omitempty"` // The RequestId that's also set in the header - StatusCode int `json:"status_code,omitempty"` // The http status code - Where string `json:"-"` // The function where it happened in the form of Struct.Func - IsOAuth bool `json:"is_oauth,omitempty"` // Whether the error is OAuth specific - params map[string]interface{} `json:"-"` + Id string `json:"id"` + Message string `json:"message"` // Message to be display to the end user without debugging information + DetailedError string `json:"detailed_error"` // Internal error string to help the developer + RequestId string `json:"request_id,omitempty"` // The RequestId that's also set in the header + StatusCode int `json:"status_code,omitempty"` // The http status code + Where string `json:"-"` // The function where it happened in the form of Struct.Func + IsOAuth bool `json:"is_oauth,omitempty"` // Whether the error is OAuth specific + params map[string]interface{} } func (er *AppError) Error() string { @@ -93,6 +93,18 @@ func AppErrorFromJson(data io.Reader) *AppError { } } +func NewAppError(where string, id string, params map[string]interface{}, details string, status int) *AppError { + ap := &AppError{} + ap.Id = id + ap.params = params + ap.Message = id + ap.Where = where + ap.DetailedError = details + ap.StatusCode = status + ap.IsOAuth = false + return ap +} + func NewLocAppError(where string, id string, params map[string]interface{}, details string) *AppError { ap := &AppError{} ap.Id = id @@ -268,7 +280,7 @@ func IsValidChannelIdentifier(s string) bool { return false } - if len(s) < 2 { + if len(s) < CHANNEL_NAME_MIN_LENGTH { return false } @@ -370,7 +382,7 @@ func ClearMentionTags(post string) string { var UrlRegex = regexp.MustCompile(`^((?:[a-z]+:\/\/)?(?:(?:[a-z0-9\-]+\.)+(?:[a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(?:\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(?:\?[a-z0-9+_~\-\.%=&]*)?)?(?:#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(?:\s+|$)$`) var PartialUrlRegex = regexp.MustCompile(`/([A-Za-z0-9]{26})/([A-Za-z0-9]{26})/((?:[A-Za-z0-9]{26})?.+(?:\.[A-Za-z0-9]{3,})?)`) -var SplitRunes = map[rune]bool{',': true, ' ': true, '.': true, '!': true, '?': true, ':': true, ';': true, '\n': true, '<': true, '>': true, '(': true, ')': true, '{': true, '}': true, '[': true, ']': true, '+': true, '/': true, '\\': true} +var SplitRunes = map[rune]bool{',': true, ' ': true, '.': true, '!': true, '?': true, ':': true, ';': true, '\n': true, '<': true, '>': true, '(': true, ')': true, '{': true, '}': true, '[': true, ']': true, '+': true, '/': true, '\\': true, '^': true, '#': true, '$': true, '&': true} func IsValidHttpUrl(rawUrl string) bool { if strings.Index(rawUrl, "http://") != 0 && strings.Index(rawUrl, "https://") != 0 { |