diff --git a/go.mod b/go.mod index 5a5ad00..a549ff2 100644 --- a/go.mod +++ b/go.mod @@ -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-20221202142825-d138a41ca8b8 + go.mau.fi/whatsmeow v0.0.0-20221213225758-70ef67df3c68 golang.org/x/image v0.1.0 golang.org/x/net v0.2.0 google.golang.org/protobuf v1.28.1 diff --git a/go.sum b/go.sum index bd62376..15ef35b 100644 --- a/go.sum +++ b/go.sum @@ -66,8 +66,8 @@ github.com/yuin/goldmark v1.5.3 h1:3HUJmBFbQW9fhQOzMgseU134xfi6hU+mjWywx5Ty+/M= github.com/yuin/goldmark v1.5.3/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.mau.fi/libsignal v0.0.0-20221015105917-d970e7c3c9cf h1:mzPxXBgDPHKDHMVV1tIWh7lwCiRpzCsXC0gNRX+K07c= go.mau.fi/libsignal v0.0.0-20221015105917-d970e7c3c9cf/go.mod h1:XCjaU93vl71YNRPn059jMrK0xRDwVO5gKbxoPxow9mQ= -go.mau.fi/whatsmeow v0.0.0-20221202142825-d138a41ca8b8 h1:NGYkG/DXj7mEAR50CT0f+pNWITmlYH8H0+pS6n95XD0= -go.mau.fi/whatsmeow v0.0.0-20221202142825-d138a41ca8b8/go.mod h1:2yweL8nczvtlIxkrvCb0y8xiO13rveX9lJPambwYV/E= +go.mau.fi/whatsmeow v0.0.0-20221213225758-70ef67df3c68 h1:uieThnMYyFDdUNDrHxauuZOW5ip+igWhHwyWFNjA2Sw= +go.mau.fi/whatsmeow v0.0.0-20221213225758-70ef67df3c68/go.mod h1:2yweL8nczvtlIxkrvCb0y8xiO13rveX9lJPambwYV/E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE= diff --git a/portal.go b/portal.go index 9370b70..448d8d4 100644 --- a/portal.go +++ b/portal.go @@ -1056,12 +1056,16 @@ func reuploadAvatar(intent *appservice.IntentAPI, url string) (id.ContentURI, er return resp.ContentURI, nil } -func (user *User) updateAvatar(jid types.JID, avatarID *string, avatarURL *id.ContentURI, avatarSet *bool, log log.Logger, intent *appservice.IntentAPI) bool { +func (user *User) updateAvatar(jid types.JID, isCommunity bool, avatarID *string, avatarURL *id.ContentURI, avatarSet *bool, log log.Logger, intent *appservice.IntentAPI) bool { currentID := "" if *avatarSet && *avatarID != "remove" && *avatarID != "unauthorized" { currentID = *avatarID } - avatar, err := user.Client.GetProfilePictureInfo(jid, false, currentID) + avatar, err := user.Client.GetProfilePictureInfo(jid, &whatsmeow.GetProfilePictureParams{ + Preview: false, + ExistingID: currentID, + IsCommunity: isCommunity, + }) if errors.Is(err, whatsmeow.ErrProfilePictureUnauthorized) { if *avatarID == "" { *avatarID = "unauthorized" @@ -1106,7 +1110,7 @@ func (user *User) updateAvatar(jid types.JID, avatarID *string, avatarURL *id.Co func (portal *Portal) UpdateAvatar(user *User, setBy types.JID, updateInfo bool) bool { portal.avatarLock.Lock() defer portal.avatarLock.Unlock() - changed := user.updateAvatar(portal.Key.JID, &portal.Avatar, &portal.AvatarURL, &portal.AvatarSet, portal.log, portal.MainIntent()) + changed := user.updateAvatar(portal.Key.JID, portal.IsParent, &portal.Avatar, &portal.AvatarURL, &portal.AvatarSet, portal.log, portal.MainIntent()) if !changed || portal.Avatar == "unauthorized" { if changed || updateInfo { portal.Update(nil) diff --git a/puppet.go b/puppet.go index 5024818..2895642 100644 --- a/puppet.go +++ b/puppet.go @@ -223,7 +223,7 @@ func (puppet *Puppet) DefaultIntent() *appservice.IntentAPI { } func (puppet *Puppet) UpdateAvatar(source *User, forcePortalSync bool) bool { - changed := source.updateAvatar(puppet.JID, &puppet.Avatar, &puppet.AvatarURL, &puppet.AvatarSet, puppet.log, puppet.DefaultIntent()) + changed := source.updateAvatar(puppet.JID, false, &puppet.Avatar, &puppet.AvatarURL, &puppet.AvatarSet, puppet.log, puppet.DefaultIntent()) if !changed || puppet.Avatar == "unauthorized" { if forcePortalSync { go puppet.updatePortalAvatar()