fix(ImageUnfurler): set title for image links (#4215)
This commit is contained in:
parent
4744ee899e
commit
a6d46756f5
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
neturl "net/url"
|
neturl "net/url"
|
||||||
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"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)
|
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.Width = width
|
||||||
preview.Thumbnail.Height = height
|
preview.Thumbnail.Height = height
|
||||||
preview.Thumbnail.DataURI = dataURI
|
preview.Thumbnail.DataURI = dataURI
|
||||||
|
|
|
@ -356,7 +356,7 @@ func (s *MessengerLinkPreviewsTestSuite) Test_UnfurlURLs_Image() {
|
||||||
Type: protobuf.UnfurledLink_IMAGE,
|
Type: protobuf.UnfurledLink_IMAGE,
|
||||||
URL: u,
|
URL: u,
|
||||||
Hostname: "placehold.co",
|
Hostname: "placehold.co",
|
||||||
Title: "",
|
Title: "600x400@3x.png",
|
||||||
Description: "",
|
Description: "",
|
||||||
Thumbnail: common.LinkPreviewThumbnail{
|
Thumbnail: common.LinkPreviewThumbnail{
|
||||||
Width: 1293,
|
Width: 1293,
|
||||||
|
|
Loading…
Reference in New Issue