summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/user.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2023-01-28 22:57:53 +0100
committerGitHub <noreply@github.com>2023-01-28 22:57:53 +0100
commit880586bac42817ffcfea5d9f746f503fa29915b8 (patch)
treea89374cba6f88975f12316ec8d1b8aa1d4c6ba79 /vendor/go.mau.fi/whatsmeow/user.go
parenteac2a8c8dc831f946970d327e2a80b26b0684255 (diff)
downloadmatterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.tar.gz
matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.tar.bz2
matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.zip
Update dependencies (#1951)
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/user.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/user.go40
1 files changed, 32 insertions, 8 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/user.go b/vendor/go.mau.fi/whatsmeow/user.go
index fe7b0971..dae86406 100644
--- a/vendor/go.mau.fi/whatsmeow/user.go
+++ b/vendor/go.mau.fi/whatsmeow/user.go
@@ -270,29 +270,53 @@ func (cli *Client) GetUserDevicesContext(ctx context.Context, jids []types.JID)
return devices, nil
}
+type GetProfilePictureParams struct {
+ Preview bool
+ ExistingID string
+ IsCommunity bool
+}
+
// GetProfilePictureInfo gets the URL where you can download a WhatsApp user's profile picture or group's photo.
//
// Optionally, you can pass the last known profile picture ID.
// If the profile picture hasn't changed, this will return nil with no error.
-func (cli *Client) GetProfilePictureInfo(jid types.JID, preview bool, existingID string) (*types.ProfilePictureInfo, error) {
+//
+// To get a community photo, you should pass `IsCommunity: true`, as otherwise you may get a 401 error.
+func (cli *Client) GetProfilePictureInfo(jid types.JID, params *GetProfilePictureParams) (*types.ProfilePictureInfo, error) {
attrs := waBinary.Attrs{
"query": "url",
}
- if preview {
+ if params == nil {
+ params = &GetProfilePictureParams{}
+ }
+ if params.Preview {
attrs["type"] = "preview"
} else {
attrs["type"] = "image"
}
- if existingID != "" {
- attrs["id"] = existingID
+ if params.ExistingID != "" {
+ attrs["id"] = params.ExistingID
+ }
+ var pictureContent []waBinary.Node
+ namespace := "w:profile:picture"
+ if params.IsCommunity {
+ namespace = "w:g2"
+ pictureContent = []waBinary.Node{{
+ Tag: "query_linked",
+ Attrs: waBinary.Attrs{
+ "type": "parent_group",
+ "jid": jid,
+ },
+ }}
}
resp, err := cli.sendIQ(infoQuery{
- Namespace: "w:profile:picture",
+ Namespace: namespace,
Type: "get",
To: jid,
Content: []waBinary.Node{{
- Tag: "picture",
- Attrs: attrs,
+ Tag: "picture",
+ Attrs: attrs,
+ Content: pictureContent,
}},
})
if errors.Is(err, ErrIQNotAuthorized) {
@@ -304,7 +328,7 @@ func (cli *Client) GetProfilePictureInfo(jid types.JID, preview bool, existingID
}
picture, ok := resp.GetOptionalChildByTag("picture")
if !ok {
- if existingID != "" {
+ if params.ExistingID != "" {
return nil, nil
}
return nil, &ElementMissingError{Tag: "picture", In: "response to profile picture query"}