MM-13015 Add safety valve setting to disable post metadata (#9877)

* MM-13015 Add safety valve setting to disable post metadata

* Remove setting from client config since it's no longer needed
Этот коммит содержится в:
Harrison Healey
2018-11-23 11:59:34 -05:00
коммит произвёл GitHub
родитель c494f6f898
Коммит 71dba81e91
4 изменённых файлов: 31 добавлений и 1 удалений

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

@@ -52,6 +52,10 @@ func (a *App) PreparePostForClient(originalPost *model.Post) *model.Post {
// Proxy image links before constructing metadata so that requests go through the proxy // Proxy image links before constructing metadata so that requests go through the proxy
post = a.PostWithProxyAddedToImageURLs(post) post = a.PostWithProxyAddedToImageURLs(post)
if *a.Config().ExperimentalSettings.DisablePostMetadata {
return post
}
post.Metadata = &model.PostMetadata{} post.Metadata = &model.PostMetadata{}
// Emojis and reaction counts // Emojis and reaction counts

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

@@ -24,6 +24,10 @@ func TestPreparePostListForClient(t *testing.T) {
th := Setup().InitBasic() th := Setup().InitBasic()
defer th.TearDown() defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ExperimentalSettings.DisablePostMetadata = false
})
postList := model.NewPostList() postList := model.NewPostList()
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
postList.AddPost(&model.Post{}) postList.AddPost(&model.Post{})
@@ -57,6 +61,7 @@ func TestPreparePostForClient(t *testing.T) {
*cfg.ServiceSettings.ImageProxyType = "" *cfg.ServiceSettings.ImageProxyType = ""
*cfg.ServiceSettings.ImageProxyURL = "" *cfg.ServiceSettings.ImageProxyURL = ""
*cfg.ServiceSettings.ImageProxyOptions = "" *cfg.ServiceSettings.ImageProxyOptions = ""
*cfg.ExperimentalSettings.DisablePostMetadata = false
}) })
return th return th
@@ -384,6 +389,20 @@ func TestPreparePostForClient(t *testing.T) {
}, imageDimensions["https://github.com/hmhealey/test-files/raw/master/icon.png"]) }, imageDimensions["https://github.com/hmhealey/test-files/raw/master/icon.png"])
}) })
}) })
t.Run("when disabled", func(t *testing.T) {
th := setup()
defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ExperimentalSettings.DisablePostMetadata = true
})
post := th.CreatePost(th.BasicChannel)
post = th.App.PreparePostForClient(post)
assert.Nil(t, post.Metadata)
})
} }
func TestPreparePostForClientWithImageProxy(t *testing.T) { func TestPreparePostForClientWithImageProxy(t *testing.T) {
@@ -395,6 +414,7 @@ func TestPreparePostForClientWithImageProxy(t *testing.T) {
*cfg.ServiceSettings.ImageProxyType = "atmos/camo" *cfg.ServiceSettings.ImageProxyType = "atmos/camo"
*cfg.ServiceSettings.ImageProxyURL = "https://127.0.0.1" *cfg.ServiceSettings.ImageProxyURL = "https://127.0.0.1"
*cfg.ServiceSettings.ImageProxyOptions = "foo" *cfg.ServiceSettings.ImageProxyOptions = "foo"
*cfg.ExperimentalSettings.DisablePostMetadata = false
}) })
return th return th

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

@@ -360,7 +360,8 @@
}, },
"ExperimentalSettings": { "ExperimentalSettings": {
"ClientSideCertEnable": false, "ClientSideCertEnable": false,
"ClientSideCertCheck": "secondary" "ClientSideCertCheck": "secondary",
"DisablePostMetadata": false
}, },
"AnalyticsSettings": { "AnalyticsSettings": {
"MaxUsersForStatistics": 2500 "MaxUsersForStatistics": 2500

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

@@ -651,6 +651,7 @@ func (s *MetricsSettings) SetDefaults() {
type ExperimentalSettings struct { type ExperimentalSettings struct {
ClientSideCertEnable *bool ClientSideCertEnable *bool
ClientSideCertCheck *string ClientSideCertCheck *string
DisablePostMetadata *bool
} }
func (s *ExperimentalSettings) SetDefaults() { func (s *ExperimentalSettings) SetDefaults() {
@@ -661,6 +662,10 @@ func (s *ExperimentalSettings) SetDefaults() {
if s.ClientSideCertCheck == nil { if s.ClientSideCertCheck == nil {
s.ClientSideCertCheck = NewString(CLIENT_SIDE_CERT_CHECK_SECONDARY_AUTH) s.ClientSideCertCheck = NewString(CLIENT_SIDE_CERT_CHECK_SECONDARY_AUTH)
} }
if s.DisablePostMetadata == nil {
s.DisablePostMetadata = NewBool(false)
}
} }
type AnalyticsSettings struct { type AnalyticsSettings struct {