Fixed MM-51060 (#22532)
* Fixed MM-51060 * Minor improvements * Breaking bigger loops * CI * Removed an unintended line change --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9c07d4e3cd
Коммит
22b3d9e4cb
@@ -363,6 +363,12 @@ func (a *App) getImagesForPost(c request.CTX, post *model.Post, imageURLs []stri
|
||||
}
|
||||
|
||||
for _, imageURL := range imageURLs {
|
||||
// prevent infinite loop if a OG image URL is the same post's permalink
|
||||
resolvedURL := resolveMetadataURL(imageURL, a.GetSiteURL())
|
||||
if looksLikeAPermalink(resolvedURL, a.GetSiteURL()) {
|
||||
continue
|
||||
}
|
||||
|
||||
if _, image, _, err := a.getLinkMetadata(c, imageURL, post.CreateAt, isNewPost, post.GetPreviewedPostProp()); err != nil {
|
||||
appErr, ok := err.(*model.AppError)
|
||||
isNotFound := ok && appErr.StatusCode == http.StatusNotFound
|
||||
@@ -651,6 +657,9 @@ func (a *App) getLinkMetadata(c request.CTX, requestURL string, timestamp int64,
|
||||
|
||||
var res *http.Response
|
||||
res, err = client.Do(request)
|
||||
if err != nil {
|
||||
mlog.Warn("error fetching OG image data", mlog.Err(err))
|
||||
}
|
||||
|
||||
if res != nil {
|
||||
body = res.Body
|
||||
|
||||
Ссылка в новой задаче
Block a user