summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/group.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-11-27 00:42:16 +0100
committerGitHub <noreply@github.com>2022-11-27 00:42:16 +0100
commit4fd0a7672777f0ed15692ae2ba47838208537558 (patch)
treeb119834a8b9ee78aa8f1b2ad05efa7da50516cbf /vendor/go.mau.fi/whatsmeow/group.go
parent6da9d567dc9195e9a5211f23a6795a41f56a1bfc (diff)
downloadmatterbridge-msglm-4fd0a7672777f0ed15692ae2ba47838208537558.tar.gz
matterbridge-msglm-4fd0a7672777f0ed15692ae2ba47838208537558.tar.bz2
matterbridge-msglm-4fd0a7672777f0ed15692ae2ba47838208537558.zip
Update dependencies (#1929)
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/group.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/group.go48
1 files changed, 31 insertions, 17 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/group.go b/vendor/go.mau.fi/whatsmeow/group.go
index 85dbf4cf..a2aa66f4 100644
--- a/vendor/go.mau.fi/whatsmeow/group.go
+++ b/vendor/go.mau.fi/whatsmeow/group.go
@@ -175,16 +175,24 @@ func (cli *Client) SetGroupTopic(jid types.JID, previousID, newID, topic string)
if newID == "" {
newID = GenerateMessageID()
}
+ attrs := waBinary.Attrs{
+ "id": newID,
+ }
+ if previousID != "" {
+ attrs["prev"] = previousID
+ }
+ content := []waBinary.Node{{
+ Tag: "body",
+ Content: []byte(topic),
+ }}
+ if len(topic) == 0 {
+ attrs["delete"] = "true"
+ content = nil
+ }
_, err := cli.sendGroupIQ(context.TODO(), iqSet, jid, waBinary.Node{
- Tag: "description",
- Attrs: waBinary.Attrs{
- "prev": previousID,
- "id": newID,
- },
- Content: []waBinary.Node{{
- Tag: "body",
- Content: []byte(topic),
- }},
+ Tag: "description",
+ Attrs: attrs,
+ Content: content,
})
return err
}
@@ -525,20 +533,26 @@ func (cli *Client) parseGroupChange(node *waBinary.Node) (*events.GroupInfo, err
NameSetBy: cag.OptionalJIDOrEmpty("s_o"),
}
case "description":
- topicChild := child.GetChildByTag("body")
- topicBytes, ok := topicChild.Content.([]byte)
- if !ok {
- return nil, fmt.Errorf("group change description has unexpected body: %s", topicChild.XMLString())
+ var topicStr string
+ _, isDelete := child.GetOptionalChildByTag("delete")
+ if !isDelete {
+ topicChild := child.GetChildByTag("body")
+ topicBytes, ok := topicChild.Content.([]byte)
+ if !ok {
+ return nil, fmt.Errorf("group change description has unexpected body: %s", topicChild.XMLString())
+ }
+ topicStr = string(topicBytes)
}
var setBy types.JID
if evt.Sender != nil {
setBy = *evt.Sender
}
evt.Topic = &types.GroupTopic{
- Topic: string(topicBytes),
- TopicID: cag.String("id"),
- TopicSetAt: evt.Timestamp,
- TopicSetBy: setBy,
+ Topic: topicStr,
+ TopicID: cag.String("id"),
+ TopicSetAt: evt.Timestamp,
+ TopicSetBy: setBy,
+ TopicDeleted: isDelete,
}
case "announcement":
evt.Announce = &types.GroupAnnounce{