summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/media.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-08-26 23:22:34 +0200
committerGitHub <noreply@github.com>2019-08-26 23:22:34 +0200
commitd525f1c9e4ac39b74575052b61c4de72de794b4e (patch)
tree90f444dd4046c7d29ed08c005648c573deb484b2 /vendor/github.com/Rhymen/go-whatsapp/media.go
parent921f2dfcdf1a6263220b55eb55716e497373dfcf (diff)
downloadmatterbridge-msglm-d525f1c9e4ac39b74575052b61c4de72de794b4e.tar.gz
matterbridge-msglm-d525f1c9e4ac39b74575052b61c4de72de794b4e.tar.bz2
matterbridge-msglm-d525f1c9e4ac39b74575052b61c4de72de794b4e.zip
Update Rhymen/go-whatsapp vendor (#876)
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/media.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/media.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/media.go b/vendor/github.com/Rhymen/go-whatsapp/media.go
index 06d48864..1bf729bb 100644
--- a/vendor/github.com/Rhymen/go-whatsapp/media.go
+++ b/vendor/github.com/Rhymen/go-whatsapp/media.go
@@ -8,8 +8,6 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
- "github.com/Rhymen/go-whatsapp/crypto/cbc"
- "github.com/Rhymen/go-whatsapp/crypto/hkdf"
"io"
"io/ioutil"
"mime/multipart"
@@ -17,6 +15,9 @@ import (
"os"
"strings"
"time"
+
+ "github.com/Rhymen/go-whatsapp/crypto/cbc"
+ "github.com/Rhymen/go-whatsapp/crypto/hkdf"
)
func Download(url string, mediaKey []byte, appInfo MediaType, fileLength int) ([]byte, error) {
@@ -73,17 +74,18 @@ func downloadMedia(url string) (file []byte, mac []byte, err error) {
return nil, nil, err
}
if resp.StatusCode != 200 {
- return nil, nil, fmt.Errorf("download failed")
+ return nil, nil, fmt.Errorf("download failed with status code %d", resp.StatusCode)
}
defer resp.Body.Close()
if resp.ContentLength <= 10 {
return nil, nil, fmt.Errorf("file to short")
}
data, err := ioutil.ReadAll(resp.Body)
- n := len(data)
if err != nil {
return nil, nil, err
}
+
+ n := len(data)
return data[:n-10], data[n-10 : n], nil
}
@@ -142,7 +144,7 @@ func (wac *Conn) Upload(reader io.Reader, appInfo MediaType) (url string, mediaK
select {
case r := <-ch:
if err = json.Unmarshal([]byte(r), &resp); err != nil {
- return "", nil, nil, nil, 0, fmt.Errorf("error decoding upload response: %v\n", err)
+ return "", nil, nil, nil, 0, fmt.Errorf("error decoding upload response: %v", err)
}
case <-time.After(wac.msgTimeout):
return "", nil, nil, nil, 0, fmt.Errorf("restore session init timed out")