summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2018-02-06 18:45:14 -0500
committerDerrick Anderson <derrick@andersonwebstudio.com>2018-02-06 18:45:14 -0500
commit9a73f9988588b6b1be5711634239381fe9e01d16 (patch)
tree1e4f71f469608d02d73afc40b3d838fe97d269ae
parent1ec295f88ca99e9423ffd91019cecf802ae3dc77 (diff)
downloadchat-9a73f9988588b6b1be5711634239381fe9e01d16.tar.gz
chat-9a73f9988588b6b1be5711634239381fe9e01d16.tar.bz2
chat-9a73f9988588b6b1be5711634239381fe9e01d16.zip
ICU-715 Change ExperimentalGroupUnreadChannels setting to allow for default on/off (#8211)
-rw-r--r--config/default.json2
-rw-r--r--i18n/en.json4
-rw-r--r--model/config.go18
-rw-r--r--model/config_test.go32
-rw-r--r--utils/config.go2
5 files changed, 54 insertions, 4 deletions
diff --git a/config/default.json b/config/default.json
index 0c07f9793..934635cb9 100644
--- a/config/default.json
+++ b/config/default.json
@@ -57,7 +57,7 @@
"CloseUnusedDirectMessages": false,
"EnableTutorial": true,
"ExperimentalEnableDefaultChannelLeaveJoinMessages": true,
- "ExperimentalGroupUnreadChannels": false,
+ "ExperimentalGroupUnreadChannels": "disabled",
"ImageProxyType": "",
"ImageProxyOptions": "",
"ImageProxyURL": ""
diff --git a/i18n/en.json b/i18n/en.json
index d3bc69d0a..d983e8855 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -4759,6 +4759,10 @@
"translation": "Invalid thumbnail width for file settings. Must be a positive number."
},
{
+ "id": "model.config.is_valid.group_unread_channels.app_error",
+ "translation": "Invalid group unread channels for service settings. Must be 'disabled', 'default_on', or 'default_off'."
+ },
+ {
"id": "model.config.is_valid.image_proxy_type.app_error",
"translation": "Invalid image proxy type for service settings."
},
diff --git a/model/config.go b/model/config.go
index b7888ab13..20011f7cb 100644
--- a/model/config.go
+++ b/model/config.go
@@ -69,6 +69,10 @@ const (
ALLOW_EDIT_POST_NEVER = "never"
ALLOW_EDIT_POST_TIME_LIMIT = "time_limit"
+ GROUP_UNREAD_CHANNELS_DISABLED = "disabled"
+ GROUP_UNREAD_CHANNELS_DEFAULT_ON = "default_on"
+ GROUP_UNREAD_CHANNELS_DEFAULT_OFF = "default_off"
+
EMAIL_BATCHING_BUFFER_SIZE = 256
EMAIL_BATCHING_INTERVAL = 30
@@ -214,7 +218,7 @@ type ServiceSettings struct {
EnablePreviewFeatures *bool
EnableTutorial *bool
ExperimentalEnableDefaultChannelLeaveJoinMessages *bool
- ExperimentalGroupUnreadChannels *bool
+ ExperimentalGroupUnreadChannels *string
ImageProxyType *string
ImageProxyURL *string
ImageProxyOptions *string
@@ -424,7 +428,11 @@ func (s *ServiceSettings) SetDefaults() {
}
if s.ExperimentalGroupUnreadChannels == nil {
- s.ExperimentalGroupUnreadChannels = NewBool(false)
+ s.ExperimentalGroupUnreadChannels = NewString(GROUP_UNREAD_CHANNELS_DISABLED)
+ } else if *s.ExperimentalGroupUnreadChannels == "0" {
+ s.ExperimentalGroupUnreadChannels = NewString(GROUP_UNREAD_CHANNELS_DISABLED)
+ } else if *s.ExperimentalGroupUnreadChannels == "1" {
+ s.ExperimentalGroupUnreadChannels = NewString(GROUP_UNREAD_CHANNELS_DEFAULT_ON)
}
if s.ImageProxyType == nil {
@@ -2070,6 +2078,12 @@ func (ss *ServiceSettings) isValid() *AppError {
return NewAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "", http.StatusBadRequest)
}
+ if *ss.ExperimentalGroupUnreadChannels != GROUP_UNREAD_CHANNELS_DISABLED &&
+ *ss.ExperimentalGroupUnreadChannels != GROUP_UNREAD_CHANNELS_DEFAULT_ON &&
+ *ss.ExperimentalGroupUnreadChannels != GROUP_UNREAD_CHANNELS_DEFAULT_OFF {
+ return NewAppError("Config.IsValid", "model.config.is_valid.group_unread_channels.app_error", nil, "", http.StatusBadRequest)
+ }
+
switch *ss.ImageProxyType {
case "", "willnorris/imageproxy":
case "atmos/camo":
diff --git a/model/config_test.go b/model/config_test.go
index ceede6be4..5510c40d0 100644
--- a/model/config_test.go
+++ b/model/config_test.go
@@ -36,6 +36,38 @@ func TestConfigDefaultFileSettingsS3SSE(t *testing.T) {
}
}
+func TestConfigDefaultServiceSettingsExperimentalGroupUnreadChannels(t *testing.T) {
+ c1 := Config{}
+ c1.SetDefaults()
+
+ if *c1.ServiceSettings.ExperimentalGroupUnreadChannels != GROUP_UNREAD_CHANNELS_DISABLED {
+ t.Fatal("ServiceSettings.ExperimentalGroupUnreadChannels should default to 'disabled'")
+ }
+
+ // This setting was briefly a boolean, so ensure that those values still work as expected
+ c1 = Config{
+ ServiceSettings: ServiceSettings{
+ ExperimentalGroupUnreadChannels: NewString("1"),
+ },
+ }
+ c1.SetDefaults()
+
+ if *c1.ServiceSettings.ExperimentalGroupUnreadChannels != GROUP_UNREAD_CHANNELS_DEFAULT_ON {
+ t.Fatal("ServiceSettings.ExperimentalGroupUnreadChannels should set true to 'default on'")
+ }
+
+ c1 = Config{
+ ServiceSettings: ServiceSettings{
+ ExperimentalGroupUnreadChannels: NewString("0"),
+ },
+ }
+ c1.SetDefaults()
+
+ if *c1.ServiceSettings.ExperimentalGroupUnreadChannels != GROUP_UNREAD_CHANNELS_DISABLED {
+ t.Fatal("ServiceSettings.ExperimentalGroupUnreadChannels should set false to 'disabled'")
+ }
+}
+
func TestMessageExportSettingsIsValidEnableExportNotSet(t *testing.T) {
fs := &FileSettings{}
mes := &MessageExportSettings{}
diff --git a/utils/config.go b/utils/config.go
index b93d673a3..9e962eef4 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -397,7 +397,7 @@ func GenerateClientConfig(c *model.Config, diagnosticId string) map[string]strin
props["EnablePreviewFeatures"] = strconv.FormatBool(*c.ServiceSettings.EnablePreviewFeatures)
props["EnableTutorial"] = strconv.FormatBool(*c.ServiceSettings.EnableTutorial)
props["ExperimentalEnableDefaultChannelLeaveJoinMessages"] = strconv.FormatBool(*c.ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages)
- props["ExperimentalGroupUnreadChannels"] = strconv.FormatBool(*c.ServiceSettings.ExperimentalGroupUnreadChannels)
+ props["ExperimentalGroupUnreadChannels"] = *c.ServiceSettings.ExperimentalGroupUnreadChannels
props["SendEmailNotifications"] = strconv.FormatBool(c.EmailSettings.SendEmailNotifications)
props["SendPushNotifications"] = strconv.FormatBool(*c.EmailSettings.SendPushNotifications)