Add EnableDefaultChannelLeaveJoinMessages config setting (#7961)

This commit is contained in:
Chris Duarte
2018-01-10 14:04:04 -08:00
committed by Christopher Speller
parent dd9ad10d70
commit 0a9200c35d
5 changed files with 125 additions and 111 deletions

View File

@@ -63,6 +63,7 @@ func (a *App) JoinDefaultChannels(teamId string, user *model.User, channelRole s
l4g.Warn("Failed to update ChannelMemberHistory table %v", result.Err) l4g.Warn("Failed to update ChannelMemberHistory table %v", result.Err)
} }
if *a.Config().ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages == true {
if requestor == nil { if requestor == nil {
if err := a.postJoinTeamMessage(user, townSquare); err != nil { if err := a.postJoinTeamMessage(user, townSquare); err != nil {
l4g.Error(utils.T("api.channel.post_user_add_remove_message_and_forget.error"), err) l4g.Error(utils.T("api.channel.post_user_add_remove_message_and_forget.error"), err)
@@ -72,6 +73,7 @@ func (a *App) JoinDefaultChannels(teamId string, user *model.User, channelRole s
l4g.Error(utils.T("api.channel.post_user_add_remove_message_and_forget.error"), err) l4g.Error(utils.T("api.channel.post_user_add_remove_message_and_forget.error"), err)
} }
} }
}
a.InvalidateCacheForChannelMembers(result.Data.(*model.Channel).Id) a.InvalidateCacheForChannelMembers(result.Data.(*model.Channel).Id)
} }
@@ -1012,6 +1014,10 @@ func (a *App) LeaveChannel(channelId string, userId string) *model.AppError {
return err return err
} }
if channel.Name == model.DEFAULT_CHANNEL && *a.Config().ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages == false {
return nil
}
a.Go(func() { a.Go(func() {
a.postLeaveChannelMessage(user, channel) a.postLeaveChannelMessage(user, channel)
}) })

View File

@@ -237,6 +237,7 @@ func (a *App) trackConfig() {
"enable_post_search": *cfg.ServiceSettings.EnablePostSearch, "enable_post_search": *cfg.ServiceSettings.EnablePostSearch,
"enable_user_statuses": *cfg.ServiceSettings.EnableUserStatuses, "enable_user_statuses": *cfg.ServiceSettings.EnableUserStatuses,
"close_unused_direct_messages": *cfg.ServiceSettings.CloseUnusedDirectMessages, "close_unused_direct_messages": *cfg.ServiceSettings.CloseUnusedDirectMessages,
"experimental_enable_default_channel_leave_join_messages": *cfg.ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages,
}) })
a.SendDiagnostic(TRACK_CONFIG_TEAM, map[string]interface{}{ a.SendDiagnostic(TRACK_CONFIG_TEAM, map[string]interface{}{

View File

@@ -55,7 +55,8 @@
"ClusterLogTimeoutMilliseconds": 2000, "ClusterLogTimeoutMilliseconds": 2000,
"EnablePreviewFeatures": true, "EnablePreviewFeatures": true,
"CloseUnusedDirectMessages": false, "CloseUnusedDirectMessages": false,
"EnableTutorial": true "EnableTutorial": true,
"ExperimentalEnableDefaultChannelLeaveJoinMessages": true
}, },
"TeamSettings": { "TeamSettings": {
"SiteName": "Mattermost", "SiteName": "Mattermost",

View File

@@ -213,6 +213,7 @@ type ServiceSettings struct {
CloseUnusedDirectMessages *bool CloseUnusedDirectMessages *bool
EnablePreviewFeatures *bool EnablePreviewFeatures *bool
EnableTutorial *bool EnableTutorial *bool
ExperimentalEnableDefaultChannelLeaveJoinMessages *bool
} }
func (s *ServiceSettings) SetDefaults() { func (s *ServiceSettings) SetDefaults() {
@@ -413,6 +414,10 @@ func (s *ServiceSettings) SetDefaults() {
if s.EnablePreviewFeatures == nil { if s.EnablePreviewFeatures == nil {
s.EnablePreviewFeatures = NewBool(true) s.EnablePreviewFeatures = NewBool(true)
} }
if s.ExperimentalEnableDefaultChannelLeaveJoinMessages == nil {
s.ExperimentalEnableDefaultChannelLeaveJoinMessages = NewBool(true)
}
} }
type ClusterSettings struct { type ClusterSettings struct {

View File

@@ -475,6 +475,7 @@ func GenerateClientConfig(c *model.Config, diagnosticId string) map[string]strin
props["CloseUnusedDirectMessages"] = strconv.FormatBool(*c.ServiceSettings.CloseUnusedDirectMessages) props["CloseUnusedDirectMessages"] = strconv.FormatBool(*c.ServiceSettings.CloseUnusedDirectMessages)
props["EnablePreviewFeatures"] = strconv.FormatBool(*c.ServiceSettings.EnablePreviewFeatures) props["EnablePreviewFeatures"] = strconv.FormatBool(*c.ServiceSettings.EnablePreviewFeatures)
props["EnableTutorial"] = strconv.FormatBool(*c.ServiceSettings.EnableTutorial) props["EnableTutorial"] = strconv.FormatBool(*c.ServiceSettings.EnableTutorial)
props["ExperimentalEnableDefaultChannelLeaveJoinMessages"] = strconv.FormatBool(*c.ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages)
props["SendEmailNotifications"] = strconv.FormatBool(c.EmailSettings.SendEmailNotifications) props["SendEmailNotifications"] = strconv.FormatBool(c.EmailSettings.SendEmailNotifications)
props["SendPushNotifications"] = strconv.FormatBool(*c.EmailSettings.SendPushNotifications) props["SendPushNotifications"] = strconv.FormatBool(*c.EmailSettings.SendPushNotifications)