Skip to content

Commit

Permalink
message: parse participants info
Browse files Browse the repository at this point in the history
messages sent to a broadcast list from the app have a list of participants, listing which contacts the message was sent to
  • Loading branch information
Hellysonrp committed Nov 27, 2024
1 parent ae900cb commit 9b963ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@ func (cli *Client) parseMsgMetaInfo(node waBinary.Node) (metaInfo types.MsgMetaI
return
}

func (cli *Client) parseMessageParticipant(node *waBinary.Node) (participant types.JID, err error) {
ag := node.AttrGetter()
participant = ag.JID("jid")
err = ag.Error()
return
}

func (cli *Client) parseMessageParticipants(node *waBinary.Node) (participants []types.JID, err error) {
children := node.GetChildren()
participants = make([]types.JID, 0, len(children))
for _, child := range children {
participant, err := cli.parseMessageParticipant(&child)
if err != nil {
return nil, err
}
participants = append(participants, participant)
}
return
}

func (cli *Client) parseMessageInfo(node *waBinary.Node) (*types.MessageInfo, error) {
var info types.MessageInfo
var err error
Expand Down Expand Up @@ -174,6 +194,11 @@ func (cli *Client) parseMessageInfo(node *waBinary.Node) (*types.MessageInfo, er
// TODO
case "trace":
// TODO
case "participants":
info.Participants, err = cli.parseMessageParticipants(&child)
if err != nil {
cli.Log.Warnf("Failed to parse <participants> node in %s: %v", info.ID, err)
}
default:
if mediaType, ok := child.AttrGetter().GetString("mediatype", false); ok {
info.MediaType = mediaType
Expand Down
2 changes: 2 additions & 0 deletions types/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ type MessageInfo struct {

VerifiedName *VerifiedName
DeviceSentMeta *DeviceSentMeta // Metadata for direct messages sent from another one of the user's own devices.

Participants []JID
}

// SourceString returns a log-friendly representation of who sent the message and where.
Expand Down

0 comments on commit 9b963ce

Please sign in to comment.