From e8943936c51450540a4f2e8e7a2f3a2af90d14db Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 7 Mar 2018 12:36:40 -0600 Subject: general cleanup (#8387) --- model/authorization.go | 13 ------------- model/channel.go | 5 ----- model/cluster_info.go | 6 ------ model/config.go | 19 ++++++------------- model/emoji.go | 4 ---- model/ldap.go | 1 - model/manifest.go | 9 --------- model/manifest_test.go | 6 +++--- model/oauth.go | 11 ----------- model/saml.go | 3 --- model/search_params.go | 6 ------ model/team.go | 9 --------- model/user.go | 6 ------ model/utils.go | 15 --------------- model/version.go | 4 ---- 15 files changed, 9 insertions(+), 108 deletions(-) (limited to 'model') diff --git a/model/authorization.go b/model/authorization.go index 9f4e36eab..34faf8bba 100644 --- a/model/authorization.go +++ b/model/authorization.go @@ -503,19 +503,6 @@ func initializeDefaultRoles() { } } -func RoleIdsToString(roles []string) string { - output := "" - for _, role := range roles { - output += role + ", " - } - - if output == "" { - return "[]" - } - - return output[:len(output)-1] -} - func init() { initializePermissions() initializeDefaultRoles() diff --git a/model/channel.go b/model/channel.go index ce812be3d..df68202d6 100644 --- a/model/channel.go +++ b/model/channel.go @@ -86,12 +86,7 @@ func (o *Channel) Etag() string { return Etag(o.Id, o.UpdateAt) } -func (o *Channel) StatsEtag() string { - return Etag(o.Id, o.ExtraUpdateAt) -} - func (o *Channel) IsValid() *AppError { - if len(o.Id) != 26 { return NewAppError("Channel.IsValid", "model.channel.is_valid.id.app_error", nil, "", http.StatusBadRequest) } diff --git a/model/cluster_info.go b/model/cluster_info.go index a8d63ec32..46a3487a9 100644 --- a/model/cluster_info.go +++ b/model/cluster_info.go @@ -6,7 +6,6 @@ package model import ( "encoding/json" "io" - "strings" ) type ClusterInfo struct { @@ -22,11 +21,6 @@ func (me *ClusterInfo) ToJson() string { return string(b) } -func (me *ClusterInfo) Copy() *ClusterInfo { - json := me.ToJson() - return ClusterInfoFromJson(strings.NewReader(json)) -} - func ClusterInfoFromJson(data io.Reader) *ClusterInfo { var me *ClusterInfo json.NewDecoder(data).Decode(&me) diff --git a/model/config.go b/model/config.go index 1b916fe13..8e1dfce0a 100644 --- a/model/config.go +++ b/model/config.go @@ -35,10 +35,6 @@ const ( SERVICE_GOOGLE = "google" SERVICE_OFFICE365 = "office365" - WEBSERVER_MODE_REGULAR = "regular" - WEBSERVER_MODE_GZIP = "gzip" - WEBSERVER_MODE_DISABLED = "disabled" - GENERIC_NO_CHANNEL_NOTIFICATION = "generic_no_channel" GENERIC_NOTIFICATION = "generic" FULL_NOTIFICATION = "full" @@ -99,15 +95,12 @@ const ( EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION = "" - SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK = "https://about.mattermost.com/default-terms/" - SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK = "https://about.mattermost.com/default-privacy-policy/" - SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK = "https://about.mattermost.com/default-about/" - SUPPORT_SETTINGS_DEFAULT_HELP_LINK = "https://about.mattermost.com/default-help/" - SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK = "https://about.mattermost.com/default-report-a-problem/" - SUPPORT_SETTINGS_DEFAULT_ADMINISTRATORS_GUIDE_LINK = "https://about.mattermost.com/administrators-guide/" - SUPPORT_SETTINGS_DEFAULT_TROUBLESHOOTING_FORUM_LINK = "https://about.mattermost.com/troubleshooting-forum/" - SUPPORT_SETTINGS_DEFAULT_COMMERCIAL_SUPPORT_LINK = "https://about.mattermost.com/commercial-support/" - SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL = "feedback@mattermost.com" + SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK = "https://about.mattermost.com/default-terms/" + SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK = "https://about.mattermost.com/default-privacy-policy/" + SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK = "https://about.mattermost.com/default-about/" + SUPPORT_SETTINGS_DEFAULT_HELP_LINK = "https://about.mattermost.com/default-help/" + SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK = "https://about.mattermost.com/default-report-a-problem/" + SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL = "feedback@mattermost.com" LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE = "" LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE = "" diff --git a/model/emoji.go b/model/emoji.go index a1703abb1..47d170bb3 100644 --- a/model/emoji.go +++ b/model/emoji.go @@ -56,10 +56,6 @@ func (emoji *Emoji) PreSave() { emoji.UpdateAt = emoji.CreateAt } -func (emoji *Emoji) PreUpdate() { - emoji.UpdateAt = GetMillis() -} - func (emoji *Emoji) ToJson() string { b, _ := json.Marshal(emoji) return string(b) diff --git a/model/ldap.go b/model/ldap.go index 1453a4add..9051c5a30 100644 --- a/model/ldap.go +++ b/model/ldap.go @@ -5,5 +5,4 @@ package model const ( USER_AUTH_SERVICE_LDAP = "ldap" - LDAP_SYNC_TASK_NAME = "LDAP Syncronization" ) diff --git a/model/manifest.go b/model/manifest.go index 5ba4854b6..fdf69c2e6 100644 --- a/model/manifest.go +++ b/model/manifest.go @@ -13,15 +13,6 @@ import ( "gopkg.in/yaml.v2" ) -const ( - PLUGIN_CONFIG_TYPE_TEXT = "text" - PLUGIN_CONFIG_TYPE_BOOL = "bool" - PLUGIN_CONFIG_TYPE_RADIO = "radio" - PLUGIN_CONFIG_TYPE_DROPDOWN = "dropdown" - PLUGIN_CONFIG_TYPE_GENERATED = "generated" - PLUGIN_CONFIG_TYPE_USERNAME = "username" -) - type PluginOption struct { // The display name for the option. DisplayName string `json:"display_name" yaml:"display_name"` diff --git a/model/manifest_test.go b/model/manifest_test.go index 3fdc13ec4..b63e388bc 100644 --- a/model/manifest_test.go +++ b/model/manifest_test.go @@ -74,7 +74,7 @@ func TestManifestUnmarshal(t *testing.T) { &PluginSetting{ Key: "thesetting", DisplayName: "thedisplayname", - Type: PLUGIN_CONFIG_TYPE_DROPDOWN, + Type: "dropdown", HelpText: "thehelptext", RegenerateHelpText: "theregeneratehelptext", Placeholder: "theplaceholder", @@ -181,7 +181,7 @@ func TestManifestJson(t *testing.T) { &PluginSetting{ Key: "thesetting", DisplayName: "thedisplayname", - Type: PLUGIN_CONFIG_TYPE_DROPDOWN, + Type: "dropdown", HelpText: "thehelptext", RegenerateHelpText: "theregeneratehelptext", Placeholder: "theplaceholder", @@ -246,7 +246,7 @@ func TestManifestClientManifest(t *testing.T) { &PluginSetting{ Key: "thesetting", DisplayName: "thedisplayname", - Type: PLUGIN_CONFIG_TYPE_DROPDOWN, + Type: "dropdown", HelpText: "thehelptext", RegenerateHelpText: "theregeneratehelptext", Placeholder: "theplaceholder", diff --git a/model/oauth.go b/model/oauth.go index 70e8a3f26..c92b1ec41 100644 --- a/model/oauth.go +++ b/model/oauth.go @@ -141,17 +141,6 @@ func OAuthAppFromJson(data io.Reader) *OAuthApp { return app } -func OAuthAppMapToJson(a map[string]*OAuthApp) string { - b, _ := json.Marshal(a) - return string(b) -} - -func OAuthAppMapFromJson(data io.Reader) map[string]*OAuthApp { - var apps map[string]*OAuthApp - json.NewDecoder(data).Decode(&apps) - return apps -} - func OAuthAppListToJson(l []*OAuthApp) string { b, _ := json.Marshal(l) return string(b) diff --git a/model/saml.go b/model/saml.go index e74750156..528ac45cc 100644 --- a/model/saml.go +++ b/model/saml.go @@ -11,9 +11,6 @@ import ( const ( USER_AUTH_SERVICE_SAML = "saml" USER_AUTH_SERVICE_SAML_TEXT = "With SAML" - SAML_IDP_CERTIFICATE = 1 - SAML_PRIVATE_KEY = 2 - SAML_PUBLIC_CERT = 3 ) type SamlAuthRequest struct { diff --git a/model/search_params.go b/model/search_params.go index 1692b3aaf..481671ab5 100644 --- a/model/search_params.go +++ b/model/search_params.go @@ -4,7 +4,6 @@ package model import ( - "encoding/json" "regexp" "strings" ) @@ -20,11 +19,6 @@ type SearchParams struct { OrTerms bool } -func (o *SearchParams) ToJson() string { - b, _ := json.Marshal(o) - return string(b) -} - var searchFlags = [...]string{"from", "channel", "in"} func splitWords(text string) []string { diff --git a/model/team.go b/model/team.go index 15a708220..7968c9d48 100644 --- a/model/team.go +++ b/model/team.go @@ -243,15 +243,6 @@ func (o *Team) Sanitize() { o.AllowedDomains = "" } -func (o *Team) SanitizeForNotLoggedIn() { - o.Email = "" - o.AllowedDomains = "" - o.CompanyName = "" - if !o.AllowOpenInvite { - o.InviteId = "" - } -} - func (t *Team) Patch(patch *TeamPatch) { if patch.DisplayName != nil { t.DisplayName = *patch.DisplayName diff --git a/model/user.go b/model/user.go index 1e1d49f7d..f64275c83 100644 --- a/model/user.go +++ b/model/user.go @@ -373,12 +373,6 @@ func (u *User) MakeNonNil() { } } -func (u *User) AddProp(key string, value string) { - u.MakeNonNil() - - u.Props[key] = value -} - func (u *User) AddNotifyProp(key string, value string) { u.MakeNonNil() diff --git a/model/utils.go b/model/utils.go index 331a1aaaa..72369852b 100644 --- a/model/utils.go +++ b/model/utils.go @@ -394,9 +394,6 @@ func ClearMentionTags(post string) string { return post } -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,})?)`) - func IsValidHttpUrl(rawUrl string) bool { if strings.Index(rawUrl, "http://") != 0 && strings.Index(rawUrl, "https://") != 0 { return false @@ -409,18 +406,6 @@ func IsValidHttpUrl(rawUrl string) bool { return true } -func IsValidHttpsUrl(rawUrl string) bool { - if strings.Index(rawUrl, "https://") != 0 { - return false - } - - if _, err := url.ParseRequestURI(rawUrl); err != nil { - return false - } - - return true -} - func IsValidTurnOrStunServer(rawUri string) bool { if strings.Index(rawUri, "turn:") != 0 && strings.Index(rawUri, "stun:") != 0 { return false diff --git a/model/version.go b/model/version.go index 3e75478d3..e4e0af491 100644 --- a/model/version.go +++ b/model/version.go @@ -107,10 +107,6 @@ func GetPreviousVersion(version string) string { return "" } -func IsOfficalBuild() bool { - return BuildNumber != "_BUILD_NUMBER_" -} - func IsCurrentVersion(versionToCheck string) bool { currentMajor, currentMinor, _ := SplitVersion(CurrentVersion) toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck) -- cgit v1.2.3-1-g7c22