MM-38081: Fix for disappearing permalink previews (#18400)
* MM-38081: Fix for disappearing previews. * MM-38081: Update method signature in tests. * MM-38081: Adds test replicating bug.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fd7bc9b4a0
Коммит
28ef5856ed
@@ -218,7 +218,7 @@ func (a *App) getEmbedForPost(post *model.Post, firstLink string, isNewPost bool
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
og, image, permalink, err := a.getLinkMetadata(firstLink, post.CreateAt, isNewPost)
|
||||
og, image, permalink, err := a.getLinkMetadata(firstLink, post.CreateAt, isNewPost, post.GetPreviewedPostProp())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -289,7 +289,7 @@ func (a *App) getImagesForPost(post *model.Post, imageURLs []string, isNewPost b
|
||||
}
|
||||
|
||||
for _, imageURL := range imageURLs {
|
||||
if _, image, _, err := a.getLinkMetadata(imageURL, post.CreateAt, isNewPost); err != nil {
|
||||
if _, image, _, err := a.getLinkMetadata(imageURL, post.CreateAt, isNewPost, post.GetPreviewedPostProp()); err != nil {
|
||||
mlog.Debug("Failed to get dimensions of an image in a post",
|
||||
mlog.String("post_id", post.Id), mlog.String("image_url", imageURL), mlog.Err(err))
|
||||
} else if image != nil {
|
||||
@@ -453,7 +453,7 @@ func looksLikeAPermalink(url, siteURL string) bool {
|
||||
return matched
|
||||
}
|
||||
|
||||
func (a *App) getLinkMetadata(requestURL string, timestamp int64, isNewPost bool) (*opengraph.OpenGraph, *model.PostImage, *model.Permalink, error) {
|
||||
func (a *App) getLinkMetadata(requestURL string, timestamp int64, isNewPost bool, previewedPostPropVal string) (*opengraph.OpenGraph, *model.PostImage, *model.Permalink, error) {
|
||||
requestURL = resolveMetadataURL(requestURL, a.GetSiteURL())
|
||||
|
||||
timestamp = model.FloorToNearestHour(timestamp)
|
||||
@@ -464,14 +464,14 @@ func (a *App) getLinkMetadata(requestURL string, timestamp int64, isNewPost bool
|
||||
permalink = nil
|
||||
}
|
||||
|
||||
if ok {
|
||||
if ok && previewedPostPropVal == "" {
|
||||
return og, image, permalink, nil
|
||||
}
|
||||
|
||||
// Check the database if this isn't a new post. If it is a new post and the data is cached, it should be in memory.
|
||||
if !isNewPost {
|
||||
og, image, ok = a.getLinkMetadataFromDatabase(requestURL, timestamp)
|
||||
if ok {
|
||||
if ok && previewedPostPropVal == "" {
|
||||
cacheLinkMetadata(requestURL, timestamp, og, image, nil)
|
||||
return og, image, nil, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user