MM-12036 Add image dimensions for other fields in message attachments (#9748)

Этот коммит содержится в:
Harrison Healey
2018-10-26 11:26:24 -04:00
родитель 18684dd6de
Коммит 2190c37359
2 изменённых файлов: 68 добавлений и 0 удалений

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

@@ -248,6 +248,22 @@ func getImagesInMessageAttachments(post *model.Post) []string {
images = append(images, imagesInFieldValue...)
}
}
if attachment.AuthorIcon != "" {
images = append(images, attachment.AuthorIcon)
}
if attachment.ImageURL != "" {
images = append(images, attachment.ImageURL)
}
if attachment.ThumbURL != "" {
images = append(images, attachment.ThumbURL)
}
if attachment.FooterIcon != "" {
images = append(images, attachment.FooterIcon)
}
}
return images

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

@@ -692,6 +692,58 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
},
Expected: []string{"https://example.com/logo2", "https://example.com/icon2"},
},
{
Name: "image in author_icon",
Post: &model.Post{
Props: map[string]interface{}{
"attachments": []*model.SlackAttachment{
{
AuthorIcon: "https://example.com/icon2",
},
},
},
},
Expected: []string{"https://example.com/icon2"},
},
{
Name: "image in image_url",
Post: &model.Post{
Props: map[string]interface{}{
"attachments": []*model.SlackAttachment{
{
ImageURL: "https://example.com/image",
},
},
},
},
Expected: []string{"https://example.com/image"},
},
{
Name: "image in thumb_url",
Post: &model.Post{
Props: map[string]interface{}{
"attachments": []*model.SlackAttachment{
{
ThumbURL: "https://example.com/image",
},
},
},
},
Expected: []string{"https://example.com/image"},
},
{
Name: "image in footer_icon",
Post: &model.Post{
Props: map[string]interface{}{
"attachments": []*model.SlackAttachment{
{
FooterIcon: "https://example.com/image",
},
},
},
},
Expected: []string{"https://example.com/image"},
},
{
Name: "images in multiple fields",
Post: &model.Post{