From d2945cdd77bdf1ee03367a0d45624094fb936c19 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Wed, 22 Aug 2018 20:12:51 +0100 Subject: MM-11782: Make archived channels experimental and off-by-default. (#9281) * MM-11782: Make archived channels experimental and off-by-default. * Fix test. --- api4/post_test.go | 20 ++++++++++++++++++++ app/channel.go | 4 ++-- app/diagnostics.go | 2 +- app/post.go | 2 +- config/default.json | 2 +- model/config.go | 6 +++--- utils/config.go | 2 +- 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/api4/post_test.go b/api4/post_test.go index 036a64fc7..910443fef 100644 --- a/api4/post_test.go +++ b/api4/post_test.go @@ -1273,6 +1273,16 @@ func TestGetPostThread(t *testing.T) { func TestSearchPosts(t *testing.T) { th := Setup().InitBasic() defer th.TearDown() + experimentalViewArchivedChannels := *th.App.Config().TeamSettings.ExperimentalViewArchivedChannels + defer func() { + th.App.UpdateConfig(func(cfg *model.Config) { + cfg.TeamSettings.ExperimentalViewArchivedChannels = &experimentalViewArchivedChannels + }) + }() + th.App.UpdateConfig(func(cfg *model.Config) { + *cfg.TeamSettings.ExperimentalViewArchivedChannels = true + }) + th.LoginBasic() Client := th.Client @@ -1316,6 +1326,16 @@ func TestSearchPosts(t *testing.T) { t.Fatal("wrong search") } + th.App.UpdateConfig(func(cfg *model.Config) { + *cfg.TeamSettings.ExperimentalViewArchivedChannels = false + }) + + posts, resp = Client.SearchPostsIncludeDeletedChannels(th.BasicTeam.Id, "#hashtag", false) + CheckNoError(t, resp) + if len(posts.Order) != 1 { + t.Fatal("wrong search") + } + if posts, resp = Client.SearchPosts(th.BasicTeam.Id, "*", false); len(posts.Order) != 0 { t.Fatal("searching for just * shouldn't return any results") } diff --git a/app/channel.go b/app/channel.go index 4dcab83ee..535eff724 100644 --- a/app/channel.go +++ b/app/channel.go @@ -1498,7 +1498,7 @@ func (a *App) UpdateChannelLastViewedAt(channelIds []string, userId string) *mod } func (a *App) AutocompleteChannels(teamId string, term string) (*model.ChannelList, *model.AppError) { - includeDeleted := *a.Config().TeamSettings.ViewArchivedChannels + includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels if result := <-a.Srv.Store.Channel().AutocompleteInTeam(teamId, term, includeDeleted); result.Err != nil { return nil, result.Err @@ -1508,7 +1508,7 @@ func (a *App) AutocompleteChannels(teamId string, term string) (*model.ChannelLi } func (a *App) SearchChannels(teamId string, term string) (*model.ChannelList, *model.AppError) { - includeDeleted := *a.Config().TeamSettings.ViewArchivedChannels + includeDeleted := *a.Config().TeamSettings.ExperimentalViewArchivedChannels if result := <-a.Srv.Store.Channel().SearchInTeam(teamId, term, includeDeleted); result.Err != nil { return nil, result.Err diff --git a/app/diagnostics.go b/app/diagnostics.go index 91341c310..7034fc1a3 100644 --- a/app/diagnostics.go +++ b/app/diagnostics.go @@ -278,7 +278,7 @@ func (a *App) trackConfig() { "max_users_per_team": *cfg.TeamSettings.MaxUsersPerTeam, "max_channels_per_team": *cfg.TeamSettings.MaxChannelsPerTeam, "teammate_name_display": *cfg.TeamSettings.TeammateNameDisplay, - "view_archived_channels": *cfg.TeamSettings.ViewArchivedChannels, + "experimental_view_archived_channels": *cfg.TeamSettings.ExperimentalViewArchivedChannels, "isdefault_site_name": isDefault(cfg.TeamSettings.SiteName, "Mattermost"), "isdefault_custom_brand_text": isDefault(*cfg.TeamSettings.CustomBrandText, model.TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT), "isdefault_custom_description_text": isDefault(*cfg.TeamSettings.CustomDescriptionText, model.TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT), diff --git a/app/post.go b/app/post.go index 299c9ce3a..0ce1bbe2d 100644 --- a/app/post.go +++ b/app/post.go @@ -648,7 +648,7 @@ func (a *App) DeletePostFiles(post *model.Post) { func (a *App) SearchPostsInTeam(terms string, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool) (*model.PostSearchResults, *model.AppError) { paramsList := model.ParseSearchParams(terms) - includeDeleted := includeDeletedChannels && *a.Config().TeamSettings.ViewArchivedChannels + includeDeleted := includeDeletedChannels && *a.Config().TeamSettings.ExperimentalViewArchivedChannels esInterface := a.Elasticsearch if license := a.License(); esInterface != nil && *a.Config().ElasticsearchSettings.EnableSearching && license != nil && *license.Features.Elasticsearch { diff --git a/config/default.json b/config/default.json index 22f94d8f0..985d3f63a 100644 --- a/config/default.json +++ b/config/default.json @@ -101,7 +101,7 @@ "MaxNotificationsPerChannel": 1000, "EnableConfirmNotificationsToChannel": true, "TeammateNameDisplay": "username", - "ViewArchivedChannels": true, + "ExperimentalViewArchivedChannels": false, "ExperimentalEnableAutomaticReplies": false, "ExperimentalHideTownSquareinLHS": false, "ExperimentalTownSquareIsReadOnly": false, diff --git a/model/config.go b/model/config.go index e38c993a8..a7044d9e1 100644 --- a/model/config.go +++ b/model/config.go @@ -1125,7 +1125,7 @@ type TeamSettings struct { MaxNotificationsPerChannel *int64 EnableConfirmNotificationsToChannel *bool TeammateNameDisplay *string - ViewArchivedChannels *bool + ExperimentalViewArchivedChannels *bool ExperimentalEnableAutomaticReplies *bool ExperimentalHideTownSquareinLHS *bool ExperimentalTownSquareIsReadOnly *bool @@ -1255,8 +1255,8 @@ func (s *TeamSettings) SetDefaults() { s.EnableUserCreation = NewBool(true) } - if s.ViewArchivedChannels == nil { - s.ViewArchivedChannels = NewBool(true) + if s.ExperimentalViewArchivedChannels == nil { + s.ExperimentalViewArchivedChannels = NewBool(false) } } diff --git a/utils/config.go b/utils/config.go index 9e445bf5c..3ce2215a3 100644 --- a/utils/config.go +++ b/utils/config.go @@ -506,7 +506,7 @@ func GenerateClientConfig(c *model.Config, diagnosticId string, license *model.L props["EnableXToLeaveChannelsFromLHS"] = strconv.FormatBool(*c.TeamSettings.EnableXToLeaveChannelsFromLHS) props["TeammateNameDisplay"] = *c.TeamSettings.TeammateNameDisplay props["ExperimentalPrimaryTeam"] = *c.TeamSettings.ExperimentalPrimaryTeam - props["ViewArchivedChannels"] = strconv.FormatBool(*c.TeamSettings.ViewArchivedChannels) + props["ExperimentalViewArchivedChannels"] = strconv.FormatBool(*c.TeamSettings.ExperimentalViewArchivedChannels) props["EnableOAuthServiceProvider"] = strconv.FormatBool(c.ServiceSettings.EnableOAuthServiceProvider) props["GoogleDeveloperKey"] = c.ServiceSettings.GoogleDeveloperKey -- cgit v1.2.3-1-g7c22