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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1cc50ff90c
Коммит
b1b9774efa
@@ -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
|
||||
|
||||
Ссылка в новой задаче
Block a user