summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/media.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-10-11 23:07:00 +0200
committerGitHub <noreply@github.com>2020-10-11 23:07:00 +0200
commit2d98df61221e23b3be557d7b1931ee3d510ac32d (patch)
tree7898a2d3c2b3003bae97d50541443072046666f3 /vendor/github.com/Rhymen/go-whatsapp/media.go
parent219a5453f9edaa87aa7aa4b9d5f9c3de9c75b38f (diff)
downloadmatterbridge-msglm-2d98df61221e23b3be557d7b1931ee3d510ac32d.tar.gz
matterbridge-msglm-2d98df61221e23b3be557d7b1931ee3d510ac32d.tar.bz2
matterbridge-msglm-2d98df61221e23b3be557d7b1931ee3d510ac32d.zip
Update vendor (#1257)
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/media.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/media.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/media.go b/vendor/github.com/Rhymen/go-whatsapp/media.go
index 43ff424f..225eac8e 100644
--- a/vendor/github.com/Rhymen/go-whatsapp/media.go
+++ b/vendor/github.com/Rhymen/go-whatsapp/media.go
@@ -129,7 +129,17 @@ func (wac *Conn) queryMediaConn() (hostname, auth string, ttl int, err error) {
return "", "", 0, fmt.Errorf("query media conn responded with %d", resp.Status)
}
- return resp.MediaConn.Hosts[0].Hostname, resp.MediaConn.Auth, resp.MediaConn.TTL, nil
+ var host string
+ for _, h := range resp.MediaConn.Hosts {
+ if h.Hostname!="" {
+ host = h.Hostname
+ break
+ }
+ }
+ if host == "" {
+ return "", "", 0, fmt.Errorf("query media conn responded with no host")
+ }
+ return host, resp.MediaConn.Auth, resp.MediaConn.TTL, nil
}
var mediaTypeMap = map[MediaType]string{
@@ -173,6 +183,10 @@ func (wac *Conn) Upload(reader io.Reader, appInfo MediaType) (downloadURL string
fileEncSha256 = sha.Sum(nil)
hostname, auth, _, err := wac.queryMediaConn()
+ if err != nil {
+ return "", nil, nil, nil, 0, err
+ }
+
token := base64.URLEncoding.EncodeToString(fileEncSha256)
q := url.Values{
"auth": []string{auth},