summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/group.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-03-12 23:02:04 +0100
committerWim <wim@42.be>2022-03-20 14:57:48 +0100
commitaefa70891cfd489fccb8a9567b5bdafb0f863ede (patch)
tree90fe7c91d7b33b2a1ed08ea3a94840860adc6fc1 /vendor/go.mau.fi/whatsmeow/group.go
parent1b9877fda45be021ea6a5677c78648cecc19dcd5 (diff)
downloadmatterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.tar.gz
matterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.tar.bz2
matterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.zip
Update vendor (whatsapp)
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/group.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/group.go37
1 files changed, 36 insertions, 1 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/group.go b/vendor/go.mau.fi/whatsmeow/group.go
index 947b11b4..34e3603f 100644
--- a/vendor/go.mau.fi/whatsmeow/group.go
+++ b/vendor/go.mau.fi/whatsmeow/group.go
@@ -106,6 +106,40 @@ func (cli *Client) UpdateGroupParticipants(jid types.JID, participantChanges map
return resp, nil
}
+// SetGroupPhoto updates the group picture/icon of the given group on WhatsApp.
+// The avatar should be a JPEG photo, other formats may be rejected with ErrInvalidImageFormat.
+// The bytes can be nil to remove the photo. Returns the new picture ID.
+func (cli *Client) SetGroupPhoto(jid types.JID, avatar []byte) (string, error) {
+ var content interface{}
+ if avatar != nil {
+ content = []waBinary.Node{{
+ Tag: "picture",
+ Attrs: waBinary.Attrs{"type": "image"},
+ Content: avatar,
+ }}
+ }
+ resp, err := cli.sendIQ(infoQuery{
+ Namespace: "w:profile:picture",
+ Type: iqSet,
+ To: types.ServerJID,
+ Target: jid,
+ Content: content,
+ })
+ if errors.Is(err, ErrIQNotAcceptable) {
+ return "", wrapIQError(ErrInvalidImageFormat, err)
+ } else if err != nil {
+ return "", err
+ }
+ if avatar == nil {
+ return "remove", nil
+ }
+ pictureID, ok := resp.GetChildByTag("picture").Attrs["id"].(string)
+ if !ok {
+ return "", fmt.Errorf("didn't find picture ID in response")
+ }
+ return pictureID, nil
+}
+
// SetGroupName updates the name (subject) of the given group on WhatsApp.
func (cli *Client) SetGroupName(jid types.JID, name string) error {
_, err := cli.sendGroupIQ(iqSet, jid, waBinary.Node{
@@ -385,7 +419,8 @@ func (cli *Client) parseGroupNode(groupNode *waBinary.Node) (*types.GroupInfo, e
case "description":
body, bodyOK := child.GetOptionalChildByTag("body")
if bodyOK {
- group.Topic, _ = body.Content.(string)
+ topicBytes, _ := body.Content.([]byte)
+ group.Topic = string(topicBytes)
group.TopicID = childAG.String("id")
group.TopicSetBy = childAG.OptionalJIDOrEmpty("participant")
group.TopicSetAt = time.Unix(childAG.Int64("t"), 0)