fix(ImageUnfurler): set title for image links (#4215)

This commit is contained in:
Igor Sirotin 2023-10-26 17:52:52 +01:00 committed by GitHub
parent 4744ee899e
commit a6d46756f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
neturl "net/url"
"path"
"regexp"
"go.uber.org/zap"
@ -105,6 +106,7 @@ func (u *ImageUnfurler) Unfurl() (*common.LinkPreview, error) {
return preview, fmt.Errorf("could not build data URI url='%s': %w", u.url.String(), err)
}
preview.Title = path.Base(u.url.Path)
preview.Thumbnail.Width = width
preview.Thumbnail.Height = height
preview.Thumbnail.DataURI = dataURI

View File

@ -356,7 +356,7 @@ func (s *MessengerLinkPreviewsTestSuite) Test_UnfurlURLs_Image() {
Type: protobuf.UnfurledLink_IMAGE,
URL: u,
Hostname: "placehold.co",
Title: "",
Title: "600x400@3x.png",
Description: "",
Thumbnail: common.LinkPreviewThumbnail{
Width: 1293,