From 4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 22 Nov 2020 15:55:57 +0100 Subject: Update vendor (#1297) --- vendor/github.com/Rhymen/go-whatsapp/media.go | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'vendor/github.com/Rhymen/go-whatsapp/media.go') diff --git a/vendor/github.com/Rhymen/go-whatsapp/media.go b/vendor/github.com/Rhymen/go-whatsapp/media.go index 225eac8e..0fcacd2e 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/media.go +++ b/vendor/github.com/Rhymen/go-whatsapp/media.go @@ -38,7 +38,7 @@ func Download(url string, mediaKey []byte, appInfo MediaType, fileLength int) ([ return nil, err } if len(data) != fileLength { - return nil, fmt.Errorf("file length does not match") + return nil, fmt.Errorf("file length does not match. Expected: %v, got: %v", fileLength, len(data)) } return data, nil } @@ -93,21 +93,21 @@ func downloadMedia(url string) (file []byte, mac []byte, err error) { return data[:n-10], data[n-10 : n], nil } - -type MediaConn struct { - Status int `json:"status"` - MediaConn struct { - Auth string `json:"auth"` - TTL int `json:"ttl"` - Hosts []struct { - Hostname string `json:"hostname"` - IPs []interface{} `json:"ips"` - } `json:"hosts"` - } `json:"media_conn"` +type MediaConn struct { + Status int `json:"status"` + MediaConn struct { + Auth string `json:"auth"` + TTL int `json:"ttl"` + Hosts []struct { + Hostname string `json:"hostname"` + IPs []struct { + IP4 string `json:"ip4"` + IP6 string `json:"ip6"` + } `json:"ips"` + } `json:"hosts"` + } `json:"media_conn"` } - - func (wac *Conn) queryMediaConn() (hostname, auth string, ttl int, err error) { queryReq := []interface{}{"query", "mediaConn"} ch, err := wac.writeJson(queryReq) @@ -131,7 +131,7 @@ func (wac *Conn) queryMediaConn() (hostname, auth string, ttl int, err error) { var host string for _, h := range resp.MediaConn.Hosts { - if h.Hostname!="" { + if h.Hostname != "" { host = h.Hostname break } @@ -143,10 +143,10 @@ func (wac *Conn) queryMediaConn() (hostname, auth string, ttl int, err error) { } var mediaTypeMap = map[MediaType]string{ - MediaImage: "/mms/image", - MediaVideo: "/mms/video", + MediaImage: "/mms/image", + MediaVideo: "/mms/video", MediaDocument: "/mms/document", - MediaAudio: "/mms/audio", + MediaAudio: "/mms/audio", } func (wac *Conn) Upload(reader io.Reader, appInfo MediaType) (downloadURL string, mediaKey []byte, fileEncSha256 []byte, fileSha256 []byte, fileLength uint64, err error) { -- cgit v1.2.3