Skip to content

Commit

Permalink
Add methods for following and unfollowing newsletters
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Oct 13, 2023
1 parent 5dd7704 commit 3d26e04
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions newsletter.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ const (
mutationUnmuteNewsletter = "6068417879924485"
mutationUpdateNewsletter = "7150902998257522"
mutationCreateNewsletter = "6234210096708695"
mutationUnfollowNewsletter = "6392786840836363"
mutationFollowNewsletter = "9926858900719341"
)

func (cli *Client) sendMexIQ(ctx context.Context, queryID string, variables map[string]any) (json.RawMessage, error) {
Expand Down Expand Up @@ -205,6 +207,20 @@ func (cli *Client) ToggleNewsletterMute(jid types.JID, mute bool) error {
return err
}

func (cli *Client) FollowNewsletter(jid types.JID) error {
_, err := cli.sendMexIQ(context.TODO(), mutationFollowNewsletter, map[string]any{
"newsletter_id": jid.String(),
})
return err
}

func (cli *Client) UnfollowNewsletter(jid types.JID) error {
_, err := cli.sendMexIQ(context.TODO(), mutationUnfollowNewsletter, map[string]any{
"newsletter_id": jid.String(),
})
return err
}

type GetNewsletterMessagesParams struct {
Count int
Before types.MessageServerID
Expand Down

0 comments on commit 3d26e04

Please sign in to comment.