Update dependencies (#1784)
This commit is contained in:
7
vendor/go.mau.fi/whatsmeow/download.go
vendored
7
vendor/go.mau.fi/whatsmeow/download.go
vendored
@@ -194,19 +194,20 @@ func (cli *Client) Download(msg DownloadableMessage) ([]byte, error) {
|
||||
|
||||
// DownloadMediaWithPath downloads an attachment by manually specifying the path and encryption details.
|
||||
func (cli *Client) DownloadMediaWithPath(directPath string, encFileHash, fileHash, mediaKey []byte, fileLength int, mediaType MediaType, mmsType string) (data []byte, err error) {
|
||||
err = cli.refreshMediaConn(false)
|
||||
var mediaConn *MediaConn
|
||||
mediaConn, err = cli.refreshMediaConn(false)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to refresh media connections: %w", err)
|
||||
}
|
||||
if len(mmsType) == 0 {
|
||||
mmsType = mediaTypeToMMSType[mediaType]
|
||||
}
|
||||
for i, host := range cli.mediaConn.Hosts {
|
||||
for i, host := range mediaConn.Hosts {
|
||||
mediaURL := fmt.Sprintf("https://%s%s&hash=%s&mms-type=%s&__wa-mms=", host.Hostname, directPath, base64.URLEncoding.EncodeToString(encFileHash), mmsType)
|
||||
data, err = cli.downloadAndDecrypt(mediaURL, mediaKey, mediaType, fileLength, encFileHash, fileHash)
|
||||
// TODO there are probably some errors that shouldn't retry
|
||||
if err != nil {
|
||||
if i >= len(cli.mediaConn.Hosts)-1 {
|
||||
if i >= len(mediaConn.Hosts)-1 {
|
||||
return nil, fmt.Errorf("failed to download media from last host: %w", err)
|
||||
}
|
||||
cli.Log.Warnf("Failed to download media: %s, trying with next host...", err)
|
||||
|
||||
Reference in New Issue
Block a user