general cleanup (#8387)
Этот коммит содержится в:
@@ -503,19 +503,6 @@ func initializeDefaultRoles() {
|
||||
}
|
||||
}
|
||||
|
||||
func RoleIdsToString(roles []string) string {
|
||||
output := ""
|
||||
for _, role := range roles {
|
||||
output += role + ", "
|
||||
}
|
||||
|
||||
if output == "" {
|
||||
return "[<NO ROLES>]"
|
||||
}
|
||||
|
||||
return output[:len(output)-1]
|
||||
}
|
||||
|
||||
func init() {
|
||||
initializePermissions()
|
||||
initializeDefaultRoles()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = ""
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -5,5 +5,4 @@ package model
|
||||
|
||||
const (
|
||||
USER_AUTH_SERVICE_LDAP = "ldap"
|
||||
LDAP_SYNC_TASK_NAME = "LDAP Syncronization"
|
||||
)
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Ссылка в новой задаче
Block a user