From 110ac3b1ec24640b229b8b14d872130b6ed54ce4 Mon Sep 17 00:00:00 2001 From: Eli Yukelzon Date: Wed, 13 Jan 2021 12:42:35 +0200 Subject: [PATCH] MM-30338 Add feature flag for collapsedthreads (#16598) Co-authored-by: Mattermod --- api4/user_test.go | 8 ++++++++ app/notification.go | 2 +- model/feature_flags.go | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/api4/user_test.go b/api4/user_test.go index 2ae5a4f1e8..1eabb4f700 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -6,6 +6,7 @@ package api4 import ( "fmt" "net/http" + "os" "regexp" "strings" "testing" @@ -5405,6 +5406,9 @@ func TestGetThreadsForUser(t *testing.T) { func TestThreadSocketEvents(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() + os.Setenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS", "true") + defer os.Unsetenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS") + th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ThreadAutoFollow = true *cfg.ServiceSettings.CollapsedThreads = model.COLLAPSED_THREADS_DEFAULT_ON @@ -5548,6 +5552,8 @@ func TestFollowThreads(t *testing.T) { func TestMaintainUnreadRepliesInThread(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() + os.Setenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS", "true") + defer os.Unsetenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS") th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ThreadAutoFollow = true *cfg.ServiceSettings.CollapsedThreads = model.COLLAPSED_THREADS_DEFAULT_ON @@ -5619,6 +5625,8 @@ func TestMaintainUnreadMentionsInThread(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() Client := th.Client + os.Setenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS", "true") + defer os.Unsetenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS") th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ThreadAutoFollow = true *cfg.ServiceSettings.CollapsedThreads = model.COLLAPSED_THREADS_DEFAULT_ON diff --git a/app/notification.go b/app/notification.go index 2251c0745c..a8acc94e58 100644 --- a/app/notification.go +++ b/app/notification.go @@ -420,7 +420,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod a.Publish(message) // If this is a reply in a thread, notify participants - if *a.Config().ServiceSettings.CollapsedThreads != model.COLLAPSED_THREADS_DISABLED && post.RootId != "" { + if a.Config().FeatureFlags.CollapsedThreads && *a.Config().ServiceSettings.CollapsedThreads != model.COLLAPSED_THREADS_DISABLED && post.RootId != "" { thread, err := a.Srv().Store.Thread().Get(post.RootId) if err != nil { return nil, errors.Wrapf(err, "cannot get thread %q", post.RootId) diff --git a/model/feature_flags.go b/model/feature_flags.go index 59b407bfa6..7eed06c5ba 100644 --- a/model/feature_flags.go +++ b/model/feature_flags.go @@ -16,6 +16,8 @@ type FeatureFlags struct { // Toggle on and off scheduled jobs for cloud user limit emails see MM-29999 CloudDelinquentEmailJobsEnabled bool + // Toggle on and off support for Collapsed Threads + CollapsedThreads bool // Feature flags to control plugin versions PluginIncidentManagement string `plugin_id:"com.mattermost.plugin-incident-management"` } @@ -24,7 +26,7 @@ func (f *FeatureFlags) SetDefaults() { f.TestFeature = "off" f.TestBoolFeature = false f.CloudDelinquentEmailJobsEnabled = false - + f.CollapsedThreads = false f.PluginIncidentManagement = "1.1.1" }