diff options
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) |