GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
fix: allow link preview thumbnail upload without explicit dimensions (#627)
Aldino Kemala6f7b44c3364
diff --git a/src/pkg/utils/general.go b/src/pkg/utils/general.goindex ebcef05a..6b3515d5 100644--- a/src/pkg/utils/general.go+++ b/src/pkg/utils/general.go@@ -255,15 +255,8 @@ func GetMetaDataFromURL(urlStr string) (meta Metadata, err error) {width := uint32(bounds.Max.X - bounds.Min.X)height := uint32(bounds.Max.Y - bounds.Min.Y)- // Check if image is square (1:1 ratio)- if width == height && width <= 200 {- // For small square images, leave width and height as nil- meta.Width = nil- meta.Height = nil- } else {- meta.Width = &width- meta.Height = &height- }+ meta.Width = &width+ meta.Height = &heightlogrus.Debugf("Image dimensions: %dx%d", width, height)}diff --git a/src/usecase/send.go b/src/usecase/send.goindex 63aeff78..ee9fcb29 100644--- a/src/usecase/send.go+++ b/src/usecase/send.go@@ -1003,7 +1003,7 @@ func (service serviceSend) SendLink(ctx context.Context, request domainSend.Link}// If we have a thumbnail image, upload it to WhatsApp's servers- if len(metadata.ImageThumb) > 0 && metadata.Height != nil && metadata.Width != nil {+ if len(metadata.ImageThumb) > 0 {uploadedThumb, err := service.uploadMedia(ctx, client, whatsmeow.MediaLinkThumbnail, metadata.ImageThumb, dataWaRecipient)if err == nil {// Update the message with the uploaded thumbnail information@@ -1011,8 +1011,12 @@ func (service serviceSend) SendLink(ctx context.Context, request domainSend.Linkmsg.ExtendedTextMessage.ThumbnailSHA256 = uploadedThumb.FileSHA256msg.ExtendedTextMessage.ThumbnailEncSHA256 = uploadedThumb.FileEncSHA256msg.ExtendedTextMessage.MediaKey = uploadedThumb.MediaKey- msg.ExtendedTextMessage.ThumbnailHeight = metadata.Height- msg.ExtendedTextMessage.ThumbnailWidth = metadata.Width+ if metadata.Height != nil {+ msg.ExtendedTextMessage.ThumbnailHeight = metadata.Height+ }+ if metadata.Width != nil {+ msg.ExtendedTextMessage.ThumbnailWidth = metadata.Width+ }} else {logrus.Warnf("Failed to upload thumbnail: %v, continue without uploaded thumbnail", err)}