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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c494f6f898
Коммит
71dba81e91
@@ -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
|
||||
post = a.PostWithProxyAddedToImageURLs(post)
|
||||
|
||||
if *a.Config().ExperimentalSettings.DisablePostMetadata {
|
||||
return post
|
||||
}
|
||||
|
||||
post.Metadata = &model.PostMetadata{}
|
||||
|
||||
// Emojis and reaction counts
|
||||
|
||||
@@ -24,6 +24,10 @@ func TestPreparePostListForClient(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ExperimentalSettings.DisablePostMetadata = false
|
||||
})
|
||||
|
||||
postList := model.NewPostList()
|
||||
for i := 0; i < 5; i++ {
|
||||
postList.AddPost(&model.Post{})
|
||||
@@ -57,6 +61,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
*cfg.ServiceSettings.ImageProxyType = ""
|
||||
*cfg.ServiceSettings.ImageProxyURL = ""
|
||||
*cfg.ServiceSettings.ImageProxyOptions = ""
|
||||
*cfg.ExperimentalSettings.DisablePostMetadata = false
|
||||
})
|
||||
|
||||
return th
|
||||
@@ -384,6 +389,20 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
}, 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) {
|
||||
@@ -395,6 +414,7 @@ func TestPreparePostForClientWithImageProxy(t *testing.T) {
|
||||
*cfg.ServiceSettings.ImageProxyType = "atmos/camo"
|
||||
*cfg.ServiceSettings.ImageProxyURL = "https://127.0.0.1"
|
||||
*cfg.ServiceSettings.ImageProxyOptions = "foo"
|
||||
*cfg.ExperimentalSettings.DisablePostMetadata = false
|
||||
})
|
||||
|
||||
return th
|
||||
|
||||
@@ -360,7 +360,8 @@
|
||||
},
|
||||
"ExperimentalSettings": {
|
||||
"ClientSideCertEnable": false,
|
||||
"ClientSideCertCheck": "secondary"
|
||||
"ClientSideCertCheck": "secondary",
|
||||
"DisablePostMetadata": false
|
||||
},
|
||||
"AnalyticsSettings": {
|
||||
"MaxUsersForStatistics": 2500
|
||||
|
||||
@@ -651,6 +651,7 @@ func (s *MetricsSettings) SetDefaults() {
|
||||
type ExperimentalSettings struct {
|
||||
ClientSideCertEnable *bool
|
||||
ClientSideCertCheck *string
|
||||
DisablePostMetadata *bool
|
||||
}
|
||||
|
||||
func (s *ExperimentalSettings) SetDefaults() {
|
||||
@@ -661,6 +662,10 @@ func (s *ExperimentalSettings) SetDefaults() {
|
||||
if s.ClientSideCertCheck == nil {
|
||||
s.ClientSideCertCheck = NewString(CLIENT_SIDE_CERT_CHECK_SECONDARY_AUTH)
|
||||
}
|
||||
|
||||
if s.DisablePostMetadata == nil {
|
||||
s.DisablePostMetadata = NewBool(false)
|
||||
}
|
||||
}
|
||||
|
||||
type AnalyticsSettings struct {
|
||||
|
||||
Ссылка в новой задаче
Block a user