Browse Source

Merge pull request #28 from norazlan/master

update fix image thumbnail
pull/48/head
Dimas Restu H 3 years ago
committed by GitHub
parent
commit
69bc10d536
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      pkg/whatsapp/whatsapp.go

11
pkg/whatsapp/whatsapp.go

@ -502,7 +502,7 @@ func WhatsAppSendImage(ctx context.Context, jid string, rjid string, imageBytes
imgThumbEncode := new(bytes.Buffer)
err = imgconv.Write(imgThumbEncode,
imgconv.Resize(imgThumbDecode, imgconv.ResizeOption{Width: 640}),
imgconv.Resize(imgThumbDecode, imgconv.ResizeOption{Width: 72}),
imgconv.FormatOption{Format: imgconv.JPEG})
if err != nil {
@ -515,6 +515,12 @@ func WhatsAppSendImage(ctx context.Context, jid string, rjid string, imageBytes
return "", errors.New("Error While Uploading Media to WhatsApp Server")
}
// Upload Image Thumbnail to WhatsApp Storage Server
imageThumbUploaded, err := WhatsAppClient[jid].Upload(ctx, imgThumbEncode.Bytes(), whatsmeow.MediaLinkThumbnail)
if err != nil {
return "", errors.New("Error while Uploading Image Thumbnail to WhatsApp Server")
}
// Compose WhatsApp Proto
msgId := whatsmeow.GenerateMessageID()
msgContent := &waproto.Message{
@ -528,6 +534,9 @@ func WhatsAppSendImage(ctx context.Context, jid string, rjid string, imageBytes
FileEncSha256: imageUploaded.FileEncSHA256,
MediaKey: imageUploaded.MediaKey,
JpegThumbnail: imgThumbEncode.Bytes(),
ThumbnailDirectPath: &imageThumbUploaded.DirectPath,
ThumbnailSha256: imageThumbUploaded.FileSHA256,
ThumbnailEncSha256: imageThumbUploaded.FileEncSHA256,
ViewOnce: proto.Bool(isViewOnce),
},
}

Loading…
Cancel
Save