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) {
|
||||
|
||||
Ссылка в новой задаче
Block a user