Skip to content

Commit

Permalink
feat: add requested at in group participants request
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroPerez92 committed Jan 28, 2025
1 parent 918c879 commit 3fb971d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (cli *Client) UpdateGroupParticipants(jid types.JID, participantChanges []t
}

// GetGroupRequestParticipants gets the list of participants that have requested to join the group.
func (cli *Client) GetGroupRequestParticipants(jid types.JID) ([]types.JID, error) {
func (cli *Client) GetGroupRequestParticipants(jid types.JID) ([]types.GroupParticipantRequest, error) {
resp, err := cli.sendGroupIQ(context.TODO(), iqGet, jid, waBinary.Node{
Tag: "membership_approval_requests",
})
Expand All @@ -188,9 +188,12 @@ func (cli *Client) GetGroupRequestParticipants(jid types.JID) ([]types.JID, erro
return nil, &ElementMissingError{Tag: "membership_approval_requests", In: "response to group request participants query"}
}
requestParticipants := request.GetChildrenByTag("membership_approval_request")
participants := make([]types.JID, len(requestParticipants))
participants := make([]types.GroupParticipantRequest, len(requestParticipants))
for i, req := range requestParticipants {
participants[i] = req.AttrGetter().JID("jid")
participants[i] = types.GroupParticipantRequest{
JID: req.AttrGetter().JID("jid"),
RequestedAt: req.AttrGetter().UnixTime("request_time"),
}
}
return participants, nil
}
Expand Down
5 changes: 5 additions & 0 deletions types/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,8 @@ type GroupLinkChange struct {
UnlinkReason GroupUnlinkReason
Group GroupLinkTarget
}

type GroupParticipantRequest struct {
JID JID
RequestedAt time.Time
}

0 comments on commit 3fb971d

Please sign in to comment.