diff options
author | Wim <wim@42.be> | 2022-06-25 00:36:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-25 00:36:16 +0200 |
commit | 4649876956ab944d2a9ea8fc98c75dc8a9f5ef08 (patch) | |
tree | 0f32da8e492cabd8eca53de319e287e6c4791c5e /vendor/go.mau.fi/whatsmeow/receipt.go | |
parent | 5604d140e3bbf5c8f6c414b1427145a0c4e36bb4 (diff) | |
download | matterbridge-msglm-4649876956ab944d2a9ea8fc98c75dc8a9f5ef08.tar.gz matterbridge-msglm-4649876956ab944d2a9ea8fc98c75dc8a9f5ef08.tar.bz2 matterbridge-msglm-4649876956ab944d2a9ea8fc98c75dc8a9f5ef08.zip |
Update dependencies (#1851)
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/receipt.go')
-rw-r--r-- | vendor/go.mau.fi/whatsmeow/receipt.go | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/receipt.go b/vendor/go.mau.fi/whatsmeow/receipt.go index 3335583c..fbfdbc2d 100644 --- a/vendor/go.mau.fi/whatsmeow/receipt.go +++ b/vendor/go.mau.fi/whatsmeow/receipt.go @@ -20,7 +20,7 @@ func (cli *Client) handleReceipt(node *waBinary.Node) { receipt, err := cli.parseReceipt(node) if err != nil { cli.Log.Warnf("Failed to parse receipt: %v", err) - } else { + } else if receipt != nil { if receipt.Type == events.ReceiptTypeRetry { go func() { err := cli.handleRetryReceipt(receipt, node) @@ -34,9 +34,29 @@ func (cli *Client) handleReceipt(node *waBinary.Node) { go cli.sendAck(node) } +func (cli *Client) handleGroupedReceipt(partialReceipt events.Receipt, participants *waBinary.Node) { + pag := participants.AttrGetter() + partialReceipt.MessageIDs = []types.MessageID{pag.String("key")} + for _, child := range participants.GetChildren() { + if child.Tag != "user" { + cli.Log.Warnf("Unexpected node in grouped receipt participants: %s", child.XMLString()) + continue + } + ag := child.AttrGetter() + receipt := partialReceipt + receipt.Timestamp = ag.UnixTime("t") + receipt.MessageSource.Sender = ag.JID("jid") + if !ag.OK() { + cli.Log.Warnf("Failed to parse user node %s in grouped receipt: %v", child.XMLString(), ag.Error()) + continue + } + go cli.dispatchEvent(&receipt) + } +} + func (cli *Client) parseReceipt(node *waBinary.Node) (*events.Receipt, error) { ag := node.AttrGetter() - source, err := cli.parseMessageSource(node) + source, err := cli.parseMessageSource(node, false) if err != nil { return nil, err } @@ -45,6 +65,16 @@ func (cli *Client) parseReceipt(node *waBinary.Node) (*events.Receipt, error) { Timestamp: ag.UnixTime("t"), Type: events.ReceiptType(ag.OptionalString("type")), } + if source.IsGroup && source.Sender.IsEmpty() { + participantTags := node.GetChildrenByTag("participants") + if len(participantTags) == 0 { + return nil, &ElementMissingError{Tag: "participants", In: "grouped receipt"} + } + for _, pcp := range participantTags { + cli.handleGroupedReceipt(receipt, &pcp) + } + return nil, nil + } mainMessageID := ag.String("id") if !ag.OK() { return nil, fmt.Errorf("failed to parse read receipt attrs: %+v", ag.Errors) |