From fbff94f3be1bf596f2b94f593687d3b162413de9 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Mon, 5 Mar 2018 07:18:22 -0500 Subject: MM-8604: emit config/license websocket events (#8371) --- model/websocket_message.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'model') diff --git a/model/websocket_message.go b/model/websocket_message.go index 8d1abecfa..76326ee3f 100644 --- a/model/websocket_message.go +++ b/model/websocket_message.go @@ -44,6 +44,8 @@ const ( WEBSOCKET_EVENT_CHANNEL_VIEWED = "channel_viewed" WEBSOCKET_EVENT_PLUGIN_ACTIVATED = "plugin_activated" // EXPERIMENTAL - SUBJECT TO CHANGE WEBSOCKET_EVENT_PLUGIN_DEACTIVATED = "plugin_deactivated" // EXPERIMENTAL - SUBJECT TO CHANGE + WEBSOCKET_EVENT_LICENSE_CHANGED = "license_changed" + WEBSOCKET_EVENT_CONFIG_CHANGED = "config_changed" ) type WebSocketMessage interface { -- cgit v1.2.3-1-g7c22 From 6b3c9a480a0174cc7d1b17d0a0d874eedecc2dd3 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 5 Mar 2018 14:39:49 -0500 Subject: Add preparatory upgrade code for 4.9 (#8408) --- model/version.go | 1 + 1 file changed, 1 insertion(+) (limited to 'model') diff --git a/model/version.go b/model/version.go index 6e461e5d5..3e75478d3 100644 --- a/model/version.go +++ b/model/version.go @@ -13,6 +13,7 @@ import ( // It should be maitained in chronological order with most current // release at the front of the list. var versions = []string{ + "4.8.0", "4.7.1", "4.7.0", "4.6.0", -- cgit v1.2.3-1-g7c22 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 From 03b6d1f652407fa9c3ec7e740e120a1c3e920de0 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 7 Mar 2018 13:53:07 -0600 Subject: respect plugin manifest webapp bundle_path (#8393) --- model/manifest.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'model') diff --git a/model/manifest.go b/model/manifest.go index fdf69c2e6..32d4341cd 100644 --- a/model/manifest.go +++ b/model/manifest.go @@ -164,6 +164,11 @@ func (m *Manifest) ClientManifest() *Manifest { cm.Name = "" cm.Description = "" cm.Backend = nil + if cm.Webapp != nil { + cm.Webapp = new(ManifestWebapp) + *cm.Webapp = *m.Webapp + cm.Webapp.BundlePath = "/static/" + m.Id + "_bundle.js" + } return cm } -- cgit v1.2.3-1-g7c22 From 5ed3b42629fa9ac4d1a9c237292afcf98e61b994 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 8 Mar 2018 06:45:36 -0500 Subject: MM-8840: Add GlobalRelay Configuration Settings (#8304) * Added new GlobalRelay config settings * Adding default values to global relay config * Migrate global relay config tests to table driven tests --- model/config.go | 47 +++++++++++++++++--- model/config_test.go | 120 +++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 153 insertions(+), 14 deletions(-) (limited to 'model') diff --git a/model/config.go b/model/config.go index 8e1dfce0a..98e331f10 100644 --- a/model/config.go +++ b/model/config.go @@ -154,6 +154,8 @@ const ( COMPLIANCE_EXPORT_TYPE_ACTIANCE = "actiance" COMPLIANCE_EXPORT_TYPE_GLOBALRELAY = "globalrelay" + GLOBALRELAY_CUSTOMER_TYPE_A9 = "A9" + GLOBALRELAY_CUSTOMER_TYPE_A10 = "A10" ) type ServiceSettings struct { @@ -1627,6 +1629,28 @@ func (s *PluginSettings) SetDefaults() { } } +type GlobalRelayMessageExportSettings struct { + CustomerType *string // must be either A9 or A10, dictates SMTP server url + SmtpUsername *string + SmtpPassword *string + EmailAddress *string // the address to send messages to +} + +func (s *GlobalRelayMessageExportSettings) SetDefaults() { + if s.CustomerType == nil { + s.CustomerType = NewString(GLOBALRELAY_CUSTOMER_TYPE_A9) + } + if s.SmtpUsername == nil { + s.SmtpUsername = NewString("") + } + if s.SmtpPassword == nil { + s.SmtpPassword = NewString("") + } + if s.EmailAddress == nil { + s.EmailAddress = NewString("") + } +} + type MessageExportSettings struct { EnableExport *bool ExportFormat *string @@ -1635,7 +1659,7 @@ type MessageExportSettings struct { BatchSize *int // formatter-specific settings - these are only expected to be non-nil if ExportFormat is set to the associated format - GlobalRelayEmailAddress *string + GlobalRelaySettings *GlobalRelayMessageExportSettings } func (s *MessageExportSettings) SetDefaults() { @@ -1666,6 +1690,11 @@ func (s *MessageExportSettings) SetDefaults() { if s.BatchSize == nil { s.BatchSize = NewInt(10000) } + + if s.GlobalRelaySettings == nil { + s.GlobalRelaySettings = &GlobalRelayMessageExportSettings{} + s.GlobalRelaySettings.SetDefaults() + } } type ConfigFunc func() *Config @@ -2199,10 +2228,18 @@ func (mes *MessageExportSettings) isValid(fs FileSettings) *AppError { } if *mes.ExportFormat == COMPLIANCE_EXPORT_TYPE_GLOBALRELAY { - // validating email addresses is hard - just make sure it contains an '@' sign - // see https://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address - if mes.GlobalRelayEmailAddress == nil || !strings.Contains(*mes.GlobalRelayEmailAddress, "@") { - return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay_email_address.app_error", nil, "", http.StatusBadRequest) + if mes.GlobalRelaySettings == nil { + return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.config_missing.app_error", nil, "", http.StatusBadRequest) + } else if mes.GlobalRelaySettings.CustomerType == nil || (*mes.GlobalRelaySettings.CustomerType != GLOBALRELAY_CUSTOMER_TYPE_A9 && *mes.GlobalRelaySettings.CustomerType != GLOBALRELAY_CUSTOMER_TYPE_A10) { + return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.customer_type.app_error", nil, "", http.StatusBadRequest) + } else if mes.GlobalRelaySettings.EmailAddress == nil || !strings.Contains(*mes.GlobalRelaySettings.EmailAddress, "@") { + // validating email addresses is hard - just make sure it contains an '@' sign + // see https://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address + return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.email_address.app_error", nil, "", http.StatusBadRequest) + } else if mes.GlobalRelaySettings.SmtpUsername == nil || *mes.GlobalRelaySettings.SmtpUsername == "" { + return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.smtp_username.app_error", nil, "", http.StatusBadRequest) + } else if mes.GlobalRelaySettings.SmtpPassword == nil || *mes.GlobalRelaySettings.SmtpPassword == "" { + return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.smtp_password.app_error", nil, "", http.StatusBadRequest) } } } diff --git a/model/config_test.go b/model/config_test.go index 919f73fd7..1f917af27 100644 --- a/model/config_test.go +++ b/model/config_test.go @@ -183,21 +183,123 @@ func TestMessageExportSettingsIsValidActiance(t *testing.T) { require.Nil(t, mes.isValid(*fs)) } -func TestMessageExportSettingsIsValidGlobalRelay(t *testing.T) { +func TestMessageExportSettingsIsValidGlobalRelaySettingsMissing(t *testing.T) { fs := &FileSettings{ DriverName: NewString("foo"), // bypass file location check } mes := &MessageExportSettings{ - EnableExport: NewBool(true), - ExportFormat: NewString(COMPLIANCE_EXPORT_TYPE_GLOBALRELAY), - ExportFromTimestamp: NewInt64(0), - DailyRunTime: NewString("15:04"), - BatchSize: NewInt(100), - GlobalRelayEmailAddress: NewString("test@mattermost.com"), + EnableExport: NewBool(true), + ExportFormat: NewString(COMPLIANCE_EXPORT_TYPE_GLOBALRELAY), + ExportFromTimestamp: NewInt64(0), + DailyRunTime: NewString("15:04"), + BatchSize: NewInt(100), } - // should pass because everything is valid - require.Nil(t, mes.isValid(*fs)) + // should fail because globalrelay settings are missing + require.Error(t, mes.isValid(*fs)) +} + +func TestMessageExportSettingsIsValidGlobalRelaySettingsInvalidCustomerType(t *testing.T) { + fs := &FileSettings{ + DriverName: NewString("foo"), // bypass file location check + } + mes := &MessageExportSettings{ + EnableExport: NewBool(true), + ExportFormat: NewString(COMPLIANCE_EXPORT_TYPE_GLOBALRELAY), + ExportFromTimestamp: NewInt64(0), + DailyRunTime: NewString("15:04"), + BatchSize: NewInt(100), + GlobalRelaySettings: &GlobalRelayMessageExportSettings{ + CustomerType: NewString("Invalid"), + EmailAddress: NewString("valid@mattermost.com"), + SmtpUsername: NewString("SomeUsername"), + SmtpPassword: NewString("SomePassword"), + }, + } + + // should fail because customer type is invalid + require.Error(t, mes.isValid(*fs)) +} + +// func TestMessageExportSettingsIsValidGlobalRelaySettingsInvalidEmailAddress(t *testing.T) { +func TestMessageExportSettingsGlobalRelaySettings(t *testing.T) { + fs := &FileSettings{ + DriverName: NewString("foo"), // bypass file location check + } + tests := []struct { + name string + value *GlobalRelayMessageExportSettings + success bool + }{ + { + "Invalid email address", + &GlobalRelayMessageExportSettings{ + CustomerType: NewString(GLOBALRELAY_CUSTOMER_TYPE_A9), + EmailAddress: NewString("invalidEmailAddress"), + SmtpUsername: NewString("SomeUsername"), + SmtpPassword: NewString("SomePassword"), + }, + false, + }, + { + "Missing smtp username", + &GlobalRelayMessageExportSettings{ + CustomerType: NewString(GLOBALRELAY_CUSTOMER_TYPE_A10), + EmailAddress: NewString("valid@mattermost.com"), + SmtpPassword: NewString("SomePassword"), + }, + false, + }, + { + "Invalid smtp username", + &GlobalRelayMessageExportSettings{ + CustomerType: NewString(GLOBALRELAY_CUSTOMER_TYPE_A10), + EmailAddress: NewString("valid@mattermost.com"), + SmtpUsername: NewString(""), + SmtpPassword: NewString("SomePassword"), + }, + false, + }, + { + "Invalid smtp password", + &GlobalRelayMessageExportSettings{ + CustomerType: NewString(GLOBALRELAY_CUSTOMER_TYPE_A10), + EmailAddress: NewString("valid@mattermost.com"), + SmtpUsername: NewString("SomeUsername"), + SmtpPassword: NewString(""), + }, + false, + }, + { + "Valid data", + &GlobalRelayMessageExportSettings{ + CustomerType: NewString(GLOBALRELAY_CUSTOMER_TYPE_A9), + EmailAddress: NewString("valid@mattermost.com"), + SmtpUsername: NewString("SomeUsername"), + SmtpPassword: NewString("SomePassword"), + }, + true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + mes := &MessageExportSettings{ + EnableExport: NewBool(true), + ExportFormat: NewString(COMPLIANCE_EXPORT_TYPE_GLOBALRELAY), + ExportFromTimestamp: NewInt64(0), + DailyRunTime: NewString("15:04"), + BatchSize: NewInt(100), + GlobalRelaySettings: tt.value, + } + + if tt.success { + require.Nil(t, mes.isValid(*fs)) + } else { + require.Error(t, mes.isValid(*fs)) + } + }) + } } func TestMessageExportSetDefaults(t *testing.T) { -- cgit v1.2.3-1-g7c22 From 302dae5bb982aad14324a4df61a018557f3dd24e Mon Sep 17 00:00:00 2001 From: Stephen Kiers Date: Fri, 9 Mar 2018 05:48:30 -0700 Subject: MM-9274- Sort Users in Channel by status (#8181) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * sort by lastActivity * added status ordering to Users * sort offline before dnd * remove data not needed * added seperate call for when order=‘status’ is on GetUser request * remove PrintLn * styling fix * remove mistake * mistake 2 * better comment * explicit if statemnt * writing tests * removed manually added mocks * generated mock * ICU-668 Added unit tests * style fix * sort by lastActivity * added status ordering to Users * sort offline before dnd * remove data not needed * added seperate call for when order=‘status’ is on GetUser request * remove PrintLn * styling fix * remove mistake * mistake 2 * better comment * explicit if statemnt * writing tests * removed manually added mocks * generated mock * ICU-668 Added unit tests * style fix * reverse dnd and offline * Fixed app.SaveStatusAndBroadcast * Fixed incorrect merge * Fixing incorrect merge again --- model/client4.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'model') diff --git a/model/client4.go b/model/client4.go index 1d71d7b3e..9e552d046 100644 --- a/model/client4.go +++ b/model/client4.go @@ -695,7 +695,7 @@ func (c *Client4) GetUsersNotInTeam(teamId string, page int, perPage int, etag s } } -// GetUsersInChannel returns a page of users on a team. Page counting starts at 0. +// GetUsersInChannel returns a page of users in a channel. Page counting starts at 0. func (c *Client4) GetUsersInChannel(channelId string, page int, perPage int, etag string) ([]*User, *Response) { query := fmt.Sprintf("?in_channel=%v&page=%v&per_page=%v", channelId, page, perPage) if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil { @@ -706,7 +706,18 @@ func (c *Client4) GetUsersInChannel(channelId string, page int, perPage int, eta } } -// GetUsersNotInChannel returns a page of users on a team. Page counting starts at 0. +// GetUsersInChannelStatus returns a page of users in a channel. Page counting starts at 0. Sorted by Status +func (c *Client4) GetUsersInChannelByStatus(channelId string, page int, perPage int, etag string) ([]*User, *Response) { + query := fmt.Sprintf("?in_channel=%v&page=%v&per_page=%v&sort=status", channelId, page, perPage) + if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil { + return nil, BuildErrorResponse(r, err) + } else { + defer closeBody(r) + return UserListFromJson(r.Body), BuildResponse(r) + } +} + +// GetUsersNotInChannel returns a page of users not in a channel. Page counting starts at 0. func (c *Client4) GetUsersNotInChannel(teamId, channelId string, page int, perPage int, etag string) ([]*User, *Response) { query := fmt.Sprintf("?in_team=%v¬_in_channel=%v&page=%v&per_page=%v", teamId, channelId, page, perPage) if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil { -- cgit v1.2.3-1-g7c22 From 426796829a4a1436c4733ee856d033c02749e64b Mon Sep 17 00:00:00 2001 From: Martin Kraft Date: Fri, 9 Mar 2018 10:30:05 -0500 Subject: MM-8839: Adds ChannelType to compliance-related model. (#8424) --- model/compliance_post.go | 3 +++ model/message_export.go | 1 + 2 files changed, 4 insertions(+) (limited to 'model') diff --git a/model/compliance_post.go b/model/compliance_post.go index 3751c5862..75e8de1f1 100644 --- a/model/compliance_post.go +++ b/model/compliance_post.go @@ -17,6 +17,7 @@ type CompliancePost struct { // From Channel ChannelName string ChannelDisplayName string + ChannelType string // From User UserUsername string @@ -45,6 +46,7 @@ func CompliancePostHeader() []string { "ChannelName", "ChannelDisplayName", + "ChannelType", "UserUsername", "UserEmail", @@ -92,6 +94,7 @@ func (me *CompliancePost) Row() []string { cleanComplianceStrings(me.ChannelName), cleanComplianceStrings(me.ChannelDisplayName), + cleanComplianceStrings(me.ChannelType), cleanComplianceStrings(me.UserUsername), cleanComplianceStrings(me.UserEmail), diff --git a/model/message_export.go b/model/message_export.go index 22641deee..6efb8c6a4 100644 --- a/model/message_export.go +++ b/model/message_export.go @@ -6,6 +6,7 @@ package model type MessageExport struct { ChannelId *string ChannelDisplayName *string + ChannelType *string UserId *string UserEmail *string -- cgit v1.2.3-1-g7c22