MM-17609 Add EnableSVGs setting (#11874)
* MM-17609 Add EnableSVGs setting * MM-17609 Return SVG images in post metadata
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9b61506c7d
Коммит
23ef7d9a62
@@ -299,6 +299,7 @@ func (a *App) trackConfig() {
|
||||
"experimental_ldap_group_sync": *cfg.ServiceSettings.ExperimentalLdapGroupSync,
|
||||
"disable_bots_when_owner_is_deactivated": *cfg.ServiceSettings.DisableBotsWhenOwnerIsDeactivated,
|
||||
"enable_bot_account_creation": *cfg.ServiceSettings.EnableBotAccountCreation,
|
||||
"enable_svgs": *cfg.ServiceSettings.EnableSVGs,
|
||||
})
|
||||
|
||||
a.SendDiagnostic(TRACK_CONFIG_TEAM, map[string]interface{}{
|
||||
|
||||
@@ -495,7 +495,13 @@ func cacheLinkMetadata(requestURL string, timestamp int64, og *opengraph.OpenGra
|
||||
}
|
||||
|
||||
func (a *App) parseLinkMetadata(requestURL string, body io.Reader, contentType string) (*opengraph.OpenGraph, *model.PostImage, error) {
|
||||
if strings.HasPrefix(contentType, "image") {
|
||||
if contentType == "image/svg+xml" {
|
||||
image := &model.PostImage{
|
||||
Format: "svg",
|
||||
}
|
||||
|
||||
return nil, image, nil
|
||||
} else if strings.HasPrefix(contentType, "image") {
|
||||
image, err := parseImages(io.LimitReader(body, MaxMetadataImageSize))
|
||||
return nil, image, err
|
||||
} else if strings.HasPrefix(contentType, "text/html") {
|
||||
|
||||
@@ -2013,6 +2013,16 @@ func TestParseLinkMetadata(t *testing.T) {
|
||||
assert.Nil(t, og)
|
||||
assert.Nil(t, dimensions)
|
||||
})
|
||||
|
||||
t.Run("svg", func(t *testing.T) {
|
||||
og, dimensions, err := th.App.parseLinkMetadata("http://example.com/image.svg", nil, "image/svg+xml")
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Nil(t, og)
|
||||
assert.Equal(t, &model.PostImage{
|
||||
Format: "svg",
|
||||
}, dimensions)
|
||||
})
|
||||
}
|
||||
|
||||
func TestParseImages(t *testing.T) {
|
||||
|
||||
@@ -42,6 +42,7 @@ func GenerateClientConfig(c *model.Config, diagnosticId string, license *model.L
|
||||
props["EnableTutorial"] = strconv.FormatBool(*c.ServiceSettings.EnableTutorial)
|
||||
props["ExperimentalEnableDefaultChannelLeaveJoinMessages"] = strconv.FormatBool(*c.ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages)
|
||||
props["ExperimentalGroupUnreadChannels"] = *c.ServiceSettings.ExperimentalGroupUnreadChannels
|
||||
props["EnableSVGs"] = strconv.FormatBool(*c.ServiceSettings.EnableSVGs)
|
||||
|
||||
// This setting is only temporary, so keep using the old setting name for the mobile and web apps
|
||||
props["ExperimentalEnablePostMetadata"] = "true"
|
||||
|
||||
@@ -307,6 +307,7 @@ type ServiceSettings struct {
|
||||
ExperimentalLdapGroupSync *bool
|
||||
DisableBotsWhenOwnerIsDeactivated *bool `restricted:"true"`
|
||||
EnableBotAccountCreation *bool
|
||||
EnableSVGs *bool
|
||||
}
|
||||
|
||||
func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
||||
@@ -667,6 +668,14 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
||||
if s.EnableBotAccountCreation == nil {
|
||||
s.EnableBotAccountCreation = NewBool(false)
|
||||
}
|
||||
|
||||
if s.EnableSVGs == nil {
|
||||
if isUpdate {
|
||||
s.EnableSVGs = NewBool(true)
|
||||
} else {
|
||||
s.EnableSVGs = NewBool(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type ClusterSettings struct {
|
||||
|
||||
Ссылка в новой задаче
Block a user