diff options
author | Wim <wim@42.be> | 2020-11-22 15:55:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-22 15:55:57 +0100 |
commit | 4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf (patch) | |
tree | 92d3b8d27cd35455eae7423e4d47aad67cc6a43b /vendor/github.com/Rhymen/go-whatsapp/media.go | |
parent | cbb46293ab670c1989bfcd9aae5d853223074038 (diff) | |
download | matterbridge-msglm-4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf.tar.gz matterbridge-msglm-4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf.tar.bz2 matterbridge-msglm-4cc2c914e634eb8c79eb61aa1bc29faf6021ffcf.zip |
Update vendor (#1297)
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/media.go')
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/media.go | 36 |
1 files changed, 18 insertions, 18 deletions
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) { |