app/post_metadata: add a type cast check for OpenGraph images (#19877)

* app/post_metadata: add a type cast check for OpenGraph images

* change log level

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-04-04 13:27:18 +03:00
коммит произвёл GitHub
родитель 1cc50ff90c
Коммит b1b9774efa
2 изменённых файлов: 30 добавлений и 1 удалений

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

@@ -295,7 +295,13 @@ func (a *App) getImagesForPost(post *model.Post, imageURLs []string, isNewPost b
imageURLs = append(imageURLs, a.getImagesInMessageAttachments(post)...)
case model.PostEmbedOpengraph:
for _, image := range embed.Data.(*opengraph.OpenGraph).Images {
openGraph, ok := embed.Data.(*opengraph.OpenGraph)
if !ok {
mlog.Warn("Could not read the image data: the data could not be casted to OpenGraph",
mlog.String("post_id", post.Id), mlog.String("data type", fmt.Sprintf("%t", embed.Data)))
continue
}
for _, image := range openGraph.Images {
var imageURL string
if image.SecureURL != "" {
imageURL = image.SecureURL