Re-request media from WhatsApp on 403

This commit is contained in:
Tulir Asokan 2023-04-10 12:18:30 +03:00
parent 139b89cd66
commit f24f3bcb79
3 changed files with 5 additions and 5 deletions

2
go.mod
View file

@ -11,7 +11,7 @@ require (
github.com/prometheus/client_golang v1.14.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tidwall/gjson v1.14.4
go.mau.fi/whatsmeow v0.0.0-20230406121024-1ee2ff1d0f52
go.mau.fi/whatsmeow v0.0.0-20230410091758-46e30e265256
golang.org/x/image v0.6.0
golang.org/x/net v0.8.0
google.golang.org/protobuf v1.28.1

4
go.sum
View file

@ -67,8 +67,8 @@ github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU=
github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mau.fi/libsignal v0.1.0 h1:vAKI/nJ5tMhdzke4cTK1fb0idJzz1JuEIpmjprueC+c=
go.mau.fi/libsignal v0.1.0/go.mod h1:R8ovrTezxtUNzCQE5PH30StOQWWeBskBsWE55vMfY9I=
go.mau.fi/whatsmeow v0.0.0-20230406121024-1ee2ff1d0f52 h1:B2n3naAC2I+Wc1wx7k7KcFsFL/PuQMe/LHw2CsOmyqQ=
go.mau.fi/whatsmeow v0.0.0-20230406121024-1ee2ff1d0f52/go.mod h1:zoTtv1CupGEyTew7TOwnBmTbHB4pVad2OzjTf5CVwa0=
go.mau.fi/whatsmeow v0.0.0-20230410091758-46e30e265256 h1:1gdFqHMjadwxo2CIeeb1SExth3k9PVV2Ud9LJBvaInM=
go.mau.fi/whatsmeow v0.0.0-20230410091758-46e30e265256/go.mod h1:zoTtv1CupGEyTew7TOwnBmTbHB4pVad2OzjTf5CVwa0=
go.mau.fi/zeroconfig v0.1.2 h1:DKOydWnhPMn65GbXZOafgkPm11BvFashZWLct0dGFto=
go.mau.fi/zeroconfig v0.1.2/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

View file

@ -2742,7 +2742,7 @@ func shallowCopyMap(data map[string]interface{}) map[string]interface{} {
}
func (portal *Portal) makeMediaBridgeFailureMessage(info *types.MessageInfo, bridgeErr error, converted *ConvertedMessage, keys *FailedMediaKeys, userFriendlyError string) *ConvertedMessage {
if errors.Is(bridgeErr, whatsmeow.ErrMediaDownloadFailedWith404) || errors.Is(bridgeErr, whatsmeow.ErrMediaDownloadFailedWith410) {
if errors.Is(bridgeErr, whatsmeow.ErrMediaDownloadFailedWith403) || errors.Is(bridgeErr, whatsmeow.ErrMediaDownloadFailedWith404) || errors.Is(bridgeErr, whatsmeow.ErrMediaDownloadFailedWith410) {
portal.log.Debugfln("Failed to bridge media for %s: %v", info.ID, bridgeErr)
} else {
portal.log.Errorfln("Failed to bridge media for %s: %v", info.ID, bridgeErr)
@ -3029,7 +3029,7 @@ func (portal *Portal) convertMediaMessage(intent *appservice.IntentAPI, source *
return portal.makeMediaBridgeFailureMessage(info, errors.New("file is too large"), converted, nil, fmt.Sprintf("Large %s not bridged - please use WhatsApp app to view", typeName))
}
data, err := source.Client.Download(msg)
if errors.Is(err, whatsmeow.ErrMediaDownloadFailedWith404) || errors.Is(err, whatsmeow.ErrMediaDownloadFailedWith410) {
if errors.Is(err, whatsmeow.ErrMediaDownloadFailedWith403) || errors.Is(err, whatsmeow.ErrMediaDownloadFailedWith404) || errors.Is(err, whatsmeow.ErrMediaDownloadFailedWith410) {
converted.Error = database.MsgErrMediaNotFound
converted.MediaKey = msg.GetMediaKey()