diff options
author | Wim <wim@42.be> | 2023-03-09 22:48:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-09 22:48:00 +0100 |
commit | 08779c29099e8940493df56d28d8aa131ac8342e (patch) | |
tree | 7ad8ce25cf371e582137e1706dd671a6bf4342d0 /vendor/go.mau.fi/whatsmeow/user.go | |
parent | d5f9cdf912d43cd2a5cb243e086fbdab9a9073b0 (diff) | |
download | matterbridge-msglm-08779c29099e8940493df56d28d8aa131ac8342e.tar.gz matterbridge-msglm-08779c29099e8940493df56d28d8aa131ac8342e.tar.bz2 matterbridge-msglm-08779c29099e8940493df56d28d8aa131ac8342e.zip |
Update dependencies (#2007)
* Update dependencies
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/user.go')
-rw-r--r-- | vendor/go.mau.fi/whatsmeow/user.go | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/user.go b/vendor/go.mau.fi/whatsmeow/user.go index dae86406..229dc4b8 100644 --- a/vendor/go.mau.fi/whatsmeow/user.go +++ b/vendor/go.mau.fi/whatsmeow/user.go @@ -286,6 +286,7 @@ func (cli *Client) GetProfilePictureInfo(jid types.JID, params *GetProfilePictur attrs := waBinary.Attrs{ "query": "url", } + var target, to types.JID if params == nil { params = &GetProfilePictureParams{} } @@ -297,27 +298,36 @@ func (cli *Client) GetProfilePictureInfo(jid types.JID, params *GetProfilePictur if params.ExistingID != "" { attrs["id"] = params.ExistingID } - var pictureContent []waBinary.Node + var expectWrapped bool + var content []waBinary.Node namespace := "w:profile:picture" if params.IsCommunity { + target = types.EmptyJID namespace = "w:g2" - pictureContent = []waBinary.Node{{ - Tag: "query_linked", - Attrs: waBinary.Attrs{ - "type": "parent_group", - "jid": jid, - }, + to = jid + attrs["parent_group_jid"] = jid + expectWrapped = true + content = []waBinary.Node{{ + Tag: "pictures", + Content: []waBinary.Node{{ + Tag: "picture", + Attrs: attrs, + }}, + }} + } else { + to = types.ServerJID + target = jid + content = []waBinary.Node{{ + Tag: "picture", + Attrs: attrs, }} } resp, err := cli.sendIQ(infoQuery{ Namespace: namespace, Type: "get", - To: jid, - Content: []waBinary.Node{{ - Tag: "picture", - Attrs: attrs, - Content: pictureContent, - }}, + To: to, + Target: target, + Content: content, }) if errors.Is(err, ErrIQNotAuthorized) { return nil, wrapIQError(ErrProfilePictureUnauthorized, err) @@ -326,6 +336,13 @@ func (cli *Client) GetProfilePictureInfo(jid types.JID, params *GetProfilePictur } else if err != nil { return nil, err } + if expectWrapped { + pics, ok := resp.GetOptionalChildByTag("pictures") + if !ok { + return nil, &ElementMissingError{Tag: "pictures", In: "response to profile picture query"} + } + resp = &pics + } picture, ok := resp.GetOptionalChildByTag("picture") if !ok { if params.ExistingID != "" { @@ -335,6 +352,9 @@ func (cli *Client) GetProfilePictureInfo(jid types.JID, params *GetProfilePictur } var info types.ProfilePictureInfo ag := picture.AttrGetter() + if ag.OptionalInt("status") == 304 { + return nil, nil + } info.ID = ag.String("id") info.URL = ag.String("url") info.Type = ag.String("type") |