System Console: Email notification content setting (#7122)

* PLT-7195: Added new config option, new license feature, and config UI to system console. Still need to implement behaviour change in email batching code

* PLT-7195: Modified batch emails to respect email notification content type setting

* PLT-7195: Tweaking the colours a bit

* PLT-7195: Added support for email notification content type setting in immediate (non-batched) notification messages. Attempted to clean up the code somewhat. Unit tests coming in a future commit

* PLT-7195: Added unit tests for non-batched emails

* Checked license when applying email content settings

* Changed return type of getFormattedPostTime
Этот коммит содержится в:
Jonathan
2017-08-05 19:52:35 -04:00
коммит произвёл Saturnino Abril
родитель 9f3713aa98
Коммит 178ccd16cb
19 изменённых файлов: 802 добавлений и 139 удалений

Просмотреть файл

@@ -66,6 +66,9 @@ const (
EMAIL_BATCHING_BUFFER_SIZE = 256
EMAIL_BATCHING_INTERVAL = 30
EMAIL_NOTIFICATION_CONTENTS_FULL = "full"
EMAIL_NOTIFICATION_CONTENTS_GENERIC = "generic"
SITENAME_MAX_LENGTH = 30
SERVICE_SETTINGS_DEFAULT_SITE_URL = ""
@@ -284,6 +287,7 @@ type EmailSettings struct {
EmailBatchingBufferSize *int
EmailBatchingInterval *int
SkipServerCertificateVerification *bool
EmailNotificationContentsType *string
}
type RateLimitSettings struct {
@@ -819,6 +823,11 @@ func (o *Config) SetDefaults() {
*o.EmailSettings.SkipServerCertificateVerification = false
}
if o.EmailSettings.EmailNotificationContentsType == nil {
o.EmailSettings.EmailNotificationContentsType = new(string)
*o.EmailSettings.EmailNotificationContentsType = EMAIL_NOTIFICATION_CONTENTS_FULL
}
if !IsSafeLink(o.SupportSettings.TermsOfServiceLink) {
*o.SupportSettings.TermsOfServiceLink = SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK
}
@@ -1550,6 +1559,10 @@ func (o *Config) IsValid() *AppError {
return NewLocAppError("Config.IsValid", "model.config.is_valid.email_batching_interval.app_error", nil, "")
}
if !(*o.EmailSettings.EmailNotificationContentsType == EMAIL_NOTIFICATION_CONTENTS_FULL || *o.EmailSettings.EmailNotificationContentsType == EMAIL_NOTIFICATION_CONTENTS_GENERIC) {
return NewLocAppError("Config.IsValid", "model.config.is_valid.email_notification_contents_type.app_error", nil, "")
}
if o.RateLimitSettings.MemoryStoreSize <= 0 {
return NewLocAppError("Config.IsValid", "model.config.is_valid.rate_mem.app_error", nil, "")
}

Просмотреть файл

@@ -15,3 +15,12 @@ func TestConfigDefaultFileSettingsDirectory(t *testing.T) {
t.Fatal("FileSettings.Directory should default to './data/'")
}
}
func TestConfigDefaultEmailNotificationContentsType(t *testing.T) {
c1 := Config{}
c1.SetDefaults()
if *c1.EmailSettings.EmailNotificationContentsType != EMAIL_NOTIFICATION_CONTENTS_FULL {
t.Fatal("EmailSettings.EmailNotificationContentsType should default to 'full'")
}
}

Просмотреть файл

@@ -37,39 +37,42 @@ type Customer struct {
}
type Features struct {
Users *int `json:"users"`
LDAP *bool `json:"ldap"`
MFA *bool `json:"mfa"`
GoogleOAuth *bool `json:"google_oauth"`
Office365OAuth *bool `json:"office365_oauth"`
Compliance *bool `json:"compliance"`
Cluster *bool `json:"cluster"`
Metrics *bool `json:"metrics"`
CustomBrand *bool `json:"custom_brand"`
MHPNS *bool `json:"mhpns"`
SAML *bool `json:"saml"`
PasswordRequirements *bool `json:"password_requirements"`
Elasticsearch *bool `json:"elastic_search"`
Announcement *bool `json:"announcement"`
Users *int `json:"users"`
LDAP *bool `json:"ldap"`
MFA *bool `json:"mfa"`
GoogleOAuth *bool `json:"google_oauth"`
Office365OAuth *bool `json:"office365_oauth"`
Compliance *bool `json:"compliance"`
Cluster *bool `json:"cluster"`
Metrics *bool `json:"metrics"`
CustomBrand *bool `json:"custom_brand"`
MHPNS *bool `json:"mhpns"`
SAML *bool `json:"saml"`
PasswordRequirements *bool `json:"password_requirements"`
Elasticsearch *bool `json:"elastic_search"`
Announcement *bool `json:"announcement"`
EmailNotificationContents *bool `json:"email_notification_contents"`
// after we enabled more features for webrtc we'll need to control them with this
FutureFeatures *bool `json:"future_features"`
}
func (f *Features) ToMap() map[string]interface{} {
return map[string]interface{}{
"ldap": *f.LDAP,
"mfa": *f.MFA,
"google": *f.GoogleOAuth,
"office365": *f.Office365OAuth,
"compliance": *f.Compliance,
"cluster": *f.Cluster,
"metrics": *f.Metrics,
"custom_brand": *f.CustomBrand,
"mhpns": *f.MHPNS,
"saml": *f.SAML,
"password": *f.PasswordRequirements,
"elastic_search": *f.Elasticsearch,
"future": *f.FutureFeatures,
"ldap": *f.LDAP,
"mfa": *f.MFA,
"google": *f.GoogleOAuth,
"office365": *f.Office365OAuth,
"compliance": *f.Compliance,
"cluster": *f.Cluster,
"metrics": *f.Metrics,
"custom_brand": *f.CustomBrand,
"mhpns": *f.MHPNS,
"saml": *f.SAML,
"password": *f.PasswordRequirements,
"elastic_search": *f.Elasticsearch,
"email_notification_contents": *f.EmailNotificationContents,
"future": *f.FutureFeatures,
}
}
@@ -148,6 +151,11 @@ func (f *Features) SetDefaults() {
f.Announcement = new(bool)
*f.Announcement = true
}
if f.EmailNotificationContents == nil {
f.EmailNotificationContents = new(bool)
*f.EmailNotificationContents = *f.FutureFeatures
}
}
func (l *License) IsExpired() bool {

Просмотреть файл

@@ -27,6 +27,7 @@ func TestLicenseFeaturesToMap(t *testing.T) {
CheckTrue(t, m["password"].(bool))
CheckTrue(t, m["elastic_search"].(bool))
CheckTrue(t, m["future"].(bool))
CheckTrue(t, m["email_notification_contents"].(bool))
}
func TestLicenseFeaturesSetDefaults(t *testing.T) {
@@ -46,6 +47,7 @@ func TestLicenseFeaturesSetDefaults(t *testing.T) {
CheckTrue(t, *f.SAML)
CheckTrue(t, *f.PasswordRequirements)
CheckTrue(t, *f.Elasticsearch)
CheckTrue(t, *f.EmailNotificationContents)
CheckTrue(t, *f.FutureFeatures)
f = Features{}
@@ -65,6 +67,7 @@ func TestLicenseFeaturesSetDefaults(t *testing.T) {
*f.SAML = true
*f.PasswordRequirements = true
*f.Elasticsearch = true
*f.EmailNotificationContents = true
f.SetDefaults()
@@ -81,6 +84,7 @@ func TestLicenseFeaturesSetDefaults(t *testing.T) {
CheckTrue(t, *f.SAML)
CheckTrue(t, *f.PasswordRequirements)
CheckTrue(t, *f.Elasticsearch)
CheckTrue(t, *f.EmailNotificationContents)
CheckFalse(t, *f.FutureFeatures)
}